From 91ca4a2d59ccf03b3a21be921458628ad11f9c16 Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Tue, 30 Dec 2014 13:27:24 +0000 Subject: [PATCH] mtapi_network_c: bugfix for partial recv --- mtapi_network_c/src/embb_mtapi_network_socket.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mtapi_network_c/src/embb_mtapi_network_socket.c b/mtapi_network_c/src/embb_mtapi_network_socket.c index f923dff..e2e7c7f 100644 --- a/mtapi_network_c/src/embb_mtapi_network_socket.c +++ b/mtapi_network_c/src/embb_mtapi_network_socket.c @@ -207,7 +207,18 @@ int embb_mtapi_network_socket_recvbuffer_sized( return 0; */ if (0 < size) { - err = recv(that->handle, buffer->data, size, 0); + char * buf = (char*)(buffer->data); + int cnt = 0; + err = recv(that->handle, buf, size, 0); + while (err > 0) { + cnt += err; + if (cnt == size) + break; + buf += err; + err = recv(that->handle, buf + cnt, size - cnt, 0); + } + if (err > 0) + err = cnt; } else { err = 0; } -- libgit2 0.26.0