Send and recv all data when necessary

Expose net_recv_all() and net_send_all(), equivalent of net_recv() and
net_send(), but that waits/retries until the requested length has been
transferred.

Use these new functions where it was (wrongly) assumed that the
requested length had been transferred.
This commit is contained in:
Romain Vimont
2018-02-15 23:55:52 +01:00
parent d646f95a31
commit a791c272bc
4 changed files with 23 additions and 2 deletions

View File

@@ -19,8 +19,12 @@ void net_cleanup(void);
socket_t net_listen(Uint32 addr, Uint16 port, int backlog);
socket_t net_accept(socket_t server_socket);
// the _all versions wait/retry until len bytes have been written/read
ssize_t net_recv(socket_t socket, void *buf, size_t len);
ssize_t net_recv_all(socket_t socket, void *buf, size_t len);
ssize_t net_send(socket_t socket, void *buf, size_t len);
ssize_t net_send_all(socket_t socket, void *buf, size_t len);
void net_close(socket_t socket);
#endif