diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-25 10:47:06 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-25 10:56:03 +0200 |
commit | 08ee3cab641f367b642bc29f6540de6be85226bd (patch) | |
tree | 887f517cbec643ab90c5647d76c26e7fb024b8cc /src/net.h | |
parent | msg: add msg_dump_unknown (diff) | |
download | cimple-08ee3cab641f367b642bc29f6540de6be85226bd.tar.gz cimple-08ee3cab641f367b642bc29f6540de6be85226bd.zip |
net: rework API
First, rename all API functions so that they start with net_.
Second, abstract the basic TCP server functionality into tcp_server.c.
This includes reworking net_accept so that it's a simple blocking
operation, and putting the callback stuff to tcp_server.c. Also, the
server now uses detached threads instead of fork(), since I want
connection handlers to share memory.
Diffstat (limited to '')
-rw-r--r-- | src/net.h | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -3,18 +3,15 @@ #include <stdlib.h> -int bind_to_port(const char *port); +int net_bind(const char *port); +int net_accept(int fd); +int net_connect(const char *host, const char *port); -typedef int (*connection_handler)(int fd, void *arg); -int accept_connection(int fd, connection_handler, void *arg); +int net_send_all(int fd, const void *, size_t); +int net_send_buf(int fd, const void *, size_t); -int connect_to_host(const char *host, const char *port); - -int send_all(int fd, const void *, size_t); -int send_buf(int fd, const void *, size_t); - -ssize_t recv_all(int fd, void *, size_t); -int recv_buf(int fd, void **, size_t *); -int recv_static(int fd, void *, size_t); +ssize_t net_recv_all(int fd, void *, size_t); +int net_recv_buf(int fd, void **, size_t *); +int net_recv_static(int fd, void *, size_t); #endif |