diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-27 22:27:01 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-27 22:27:01 -0600 |
commit | 7ec97df3ee8edfd102fe573eaa61cf4e5c6284cb (patch) | |
tree | e696f30da5645cdd3cb09971d9544622e9943bcf /libnetio/include | |
parent | fa357459f88bb8f0170d1a68df66e7d068d59996 (diff) |
wip fixes
Diffstat (limited to 'libnetio/include')
-rw-r--r-- | libnetio/include/libnetio/netio.h | 20 |
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_ */ |