1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <netinet/in.h> #ifndef __TSOCKET_H #define __TSOCKET_H struct tsocket { int fd; const char *addr; int port; }; struct tsocket *tsocketNew(); int tsocketBind(struct tsocket *sock, const char *addr, int hostport); int tsocketListen(struct tsocket *sock); struct tsocket *tsocketAccept(struct tsocket *sock); void tsocketDelete(struct tsocket *sock); #endif