From 48baa618f0095642d49d18f86401c993e18d7c97 Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Wed, 31 Dec 2014 11:23:51 +0000 Subject: [PATCH] mtapi_network_c: bugfix for partial send --- mtapi_network_c/src/embb_mtapi_network_socket.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mtapi_network_c/src/embb_mtapi_network_socket.c b/mtapi_network_c/src/embb_mtapi_network_socket.c index 07d4e82..75fed54 100644 --- a/mtapi_network_c/src/embb_mtapi_network_socket.c +++ b/mtapi_network_c/src/embb_mtapi_network_socket.c @@ -177,8 +177,17 @@ int embb_mtapi_network_socket_select( int embb_mtapi_network_socket_sendbuffer( embb_mtapi_network_socket_t * that, embb_mtapi_network_buffer_t * buffer) { - int result = send(that->handle, buffer->data, buffer->size, 0); - if (result == buffer->size) { + char * buf = (char*)(buffer->data); + int cnt = 0; + int result = send(that->handle, buf, buffer->size, 0); + while (result > 0) { + buf += result; + cnt += result; + if (cnt == buffer->size) + break; + result = send(that->handle, buf, buffer->size - cnt, 0); + } + if (cnt == buffer->size) { return buffer->size; } else { return 0; -- libgit2 0.26.0