From a9501d10847d7993fad2e0778fe9c11317b4f7be Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Thu, 1 Dec 2022 23:20:33 +0800 Subject: Simplify logic by structure --- tsocket.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tsocket.h (limited to 'tsocket.h') diff --git a/tsocket.h b/tsocket.h new file mode 100644 index 0000000..5a8826c --- /dev/null +++ b/tsocket.h @@ -0,0 +1,18 @@ +#include + +#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 -- cgit v1.2.3