summaryrefslogtreecommitdiff
path: root/libnetio/include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-27 22:27:01 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-27 22:27:01 -0600
commit7ec97df3ee8edfd102fe573eaa61cf4e5c6284cb (patch)
treee696f30da5645cdd3cb09971d9544622e9943bcf /libnetio/include
parentfa357459f88bb8f0170d1a68df66e7d068d59996 (diff)
wip fixes
Diffstat (limited to 'libnetio/include')
-rw-r--r--libnetio/include/libnetio/netio.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/libnetio/include/libnetio/netio.h b/libnetio/include/libnetio/netio.h
new file mode 100644
index 0000000..9383c54
--- /dev/null
+++ b/libnetio/include/libnetio/netio.h
@@ -0,0 +1,20 @@
+#ifndef _NETIO_H_
+#define _NETIO_H_
+
+#include <stdbool.h> /* for bool */
+#include <stdint.h> /* for uint16_t */
+#include <stddef.h> /* for size_t */
+#include <sys/types.h> /* for ssize_t */
+
+/** Return socket-fd on success, -errno on error. */
+int netio_listen(uint16_t port);
+/** Return connection-fd on success, -errno on error. */
+int netio_accept(int sock);
+/** Return bytes-read on success, 0 on EOF, -errno on error; a short read is *not* an error. */
+ssize_t netio_read(int conn, void *buf, size_t count);
+/** Return `count` on success, -errno on error; a short write *is* an error. */
+ssize_t netio_write(int conn, void *buf, size_t count);
+/** Return 0 on success, -errno on error. */
+int netio_close(int conn, bool rd, bool wr);
+
+#endif /* _NETIO_H_ */