TcpServer/TcpReactor Framework
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include <c_AddrInfo.h>
|
||||
|
||||
c_err_t c_AddrInfo_Init(c_AddrInfo_t* self,
|
||||
int family,
|
||||
int socktype,
|
||||
int flags,
|
||||
const char* server, const char* port) {
|
||||
|
||||
struct addrinfo hints={0};
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = socktype;
|
||||
hints.ai_flags = flags;
|
||||
|
||||
int err = getaddrinfo(server, port, &hints, &self->addrinfo_p);
|
||||
if (err != 0) {
|
||||
self->addrinfo_p = NULL;
|
||||
return C_ERR_FAIL;
|
||||
}
|
||||
|
||||
return C_ERR_OK;
|
||||
}
|
||||
|
||||
void c_AddrInfo_Destroy(c_AddrInfo_t* self) {
|
||||
if (!self || !self->addrinfo_p) {
|
||||
return;
|
||||
}
|
||||
freeaddrinfo(self->addrinfo_p);
|
||||
self->addrinfo_p = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user