TcpServer/TcpReactor Framework
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#ifndef INCLUDED_C_ADDRINFO_H
|
||||
#define INCLUDED_C_ADDRINFO_H
|
||||
|
||||
#ifndef INCLUDED_C_SOCKET_H
|
||||
#include <c_Socket.h>
|
||||
#endif /*INCLUDED_C_SOCKET_H*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
typedef struct {
|
||||
struct addrinfo* addrinfo_p;
|
||||
}c_AddrInfo_t;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
c_err_t c_AddrInfo_Init(c_AddrInfo_t* self,
|
||||
int family,
|
||||
int socktype,
|
||||
int flags,
|
||||
const char* server, const char* port);
|
||||
|
||||
void c_AddrInfo_Destroy(c_AddrInfo_t* self);
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
c_err_t c_AddrInfo_GetNext(c_AddrInfo_t* self, c_AddrInfo_t* next){
|
||||
if (!self || !self->addrinfo_p) return C_ERR_PARAM;
|
||||
if (next) {
|
||||
next->addrinfo_p = self->addrinfo_p->ai_next;
|
||||
}
|
||||
return C_ERR_OK;
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
int c_AddrInfo_GetFlags(c_AddrInfo_t* self) {
|
||||
if (!self || !self->addrinfo_p) return -1;
|
||||
return self->addrinfo_p->ai_flags;
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
int c_AddrInfo_GetFamily(c_AddrInfo_t* self) {
|
||||
if (!self || !self->addrinfo_p) return -1;
|
||||
return self->addrinfo_p->ai_family;
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
int c_AddrInfo_GetSockType(c_AddrInfo_t* self) {
|
||||
if (!self || !self->addrinfo_p) return -1;
|
||||
return self->addrinfo_p->ai_socktype;
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
int c_AddrInfo_GetProtocol(c_AddrInfo_t* self) {
|
||||
if (!self || !self->addrinfo_p) return -1;
|
||||
return self->addrinfo_p->ai_protocol;
|
||||
}
|
||||
|
||||
#endif /*INCLUDED_C_ADDRINFO_H*/
|
||||
Reference in New Issue
Block a user