TcpServer/TcpReactor Framework

This commit is contained in:
2026-09-08 10:35:16 +08:00
parent 4711ab6603
commit ac4045a979
23 changed files with 1831 additions and 20 deletions
+30
View File
@@ -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;
}