summaryrefslogtreecommitdiff
path: root/netio.h
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-24 22:22:32 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-24 22:22:32 -0600
commit729663cb9d20b0d36b3ef6b689447390b94006df (patch)
treee91f6b82b5bf4f0265518820dbd7ffe4fcd2bb4c /netio.h
parent0b7bd5db8b2539d2e03b3a13b91ee6b21101460d (diff)
wip config, 9p
Diffstat (limited to 'netio.h')
-rw-r--r--netio.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/netio.h b/netio.h
index 8d9fa50..8497330 100644
--- a/netio.h
+++ b/netio.h
@@ -1,13 +1,18 @@
#ifndef _NETIO_H_
#define _NETIO_H_
-#include <stdint.h>
-#include <stdbool.h>
+#include <stdbool.h> /* for bool */
+#include <stdint.h> /* for size_t, ssize_t, uint16_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);
-size_t netio_read(int conn, void *buf, size_t count);
-size_t netio_write(int conn, void *buf, size_t count);
+/** 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_ */