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

@@ -3,7 +3,7 @@
SDL_bool device_read_info(socket_t device_socket, char *device_name, struct size *size) {
unsigned char buf[DEVICE_NAME_FIELD_LENGTH + 4];
int r = net_recv(device_socket, buf, sizeof(buf));
int r = net_recv_all(device_socket, buf, sizeof(buf));
if (r < DEVICE_NAME_FIELD_LENGTH + 4) {
LOGE("Could not retrieve device information");
return SDL_FALSE;