aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/msg.c
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-08-25 10:47:06 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-08-25 10:56:03 +0200
commit08ee3cab641f367b642bc29f6540de6be85226bd (patch)
tree887f517cbec643ab90c5647d76c26e7fb024b8cc /src/msg.c
parentmsg: add msg_dump_unknown (diff)
downloadcimple-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 'src/msg.c')
-rw-r--r--src/msg.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/msg.c b/src/msg.c
index b87052c..fc0b93c 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -104,7 +104,7 @@ int msg_send(int fd, const struct msg *msg)
}
arr_pack(buf, msg->argc, msg->argv);
- ret = send_buf(fd, buf, len);
+ ret = net_send_buf(fd, buf, len);
if (ret < 0)
goto free_buf;
@@ -122,7 +122,7 @@ int msg_send_and_wait_for_result(int fd, const struct msg *msg, int *result)
if (ret < 0)
return ret;
- ret = recv_static(fd, result, sizeof(*result));
+ ret = net_recv_static(fd, result, sizeof(*result));
if (ret < 0)
return ret;
@@ -135,7 +135,7 @@ int msg_recv(int fd, struct msg *msg)
size_t len;
int ret = 0;
- ret = recv_buf(fd, &buf, &len);
+ ret = net_recv_buf(fd, &buf, &len);
if (ret < 0)
return ret;
@@ -174,7 +174,7 @@ int msg_recv_and_send_result(int fd, msg_handler handler, void *arg)
result = handler(&msg, arg);
- ret = send_buf(fd, &result, sizeof(result));
+ ret = net_send_buf(fd, &result, sizeof(result));
if (ret < 0)
goto free_msg;