diff options
Diffstat (limited to 'libnetio/netio.h')
-rw-r--r-- | libnetio/netio.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libnetio/netio.h b/libnetio/netio.h new file mode 100644 index 0000000..8497330 --- /dev/null +++ b/libnetio/netio.h @@ -0,0 +1,18 @@ +#ifndef _NETIO_H_ +#define _NETIO_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); +/** 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_ */ |