aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/net.h
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-08-22 13:40:27 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-08-23 21:44:04 +0200
commit1ce4acb85a3bcb953c0f9cc91d2edc855969948b (patch)
treec06abb52fef74d375c87a7bdf39e7777bbf1b3b1 /src/net.h
parentadd doc/rationale.md (diff)
downloadcimple-1ce4acb85a3bcb953c0f9cc91d2edc855969948b.tar.gz
cimple-1ce4acb85a3bcb953c0f9cc91d2edc855969948b.zip
add some code
A basic client-server app, the client sends commands as an array of strings. Hopefully I didn't mess up, and hopefully it'll be useful.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
new file mode 100644
index 0000000..31150e8
--- /dev/null
+++ b/src/net.h
@@ -0,0 +1,20 @@
+#ifndef __NET_H__
+#define __NET_H__
+
+#include <stdlib.h>
+
+int bind_to_port(const char *port);
+
+typedef int (*connection_handler)(int fd, void *arg);
+int accept_connection(int fd, connection_handler, void *arg);
+
+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);
+
+int recv_all(int fd, void *, size_t);
+int recv_buf(int fd, void **, size_t *);
+int recv_static(int fd, void *, size_t);
+
+#endif