From 28373a9f6ec671d04bd42f3ae4e635155e734c7d Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 8 Nov 2010 01:14:23 +0100 Subject: [PATCH] Nog een poging... --- util/ddv_socket.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/util/ddv_socket.cpp b/util/ddv_socket.cpp index 1217293a..56e298de 100644 --- a/util/ddv_socket.cpp +++ b/util/ddv_socket.cpp @@ -37,19 +37,31 @@ int DDV_Accept(int sock){ } bool DDV_write(void * buffer, int width, int count, int sock){ - bool r = (send(sock, buffer, width*count, 0) == width*count); - if (!r){ - socketError = true; - printf("Could not write! %s\n", strerror(errno)); + int sofar = 0; + int todo = width*count; + while (sofar != todo){ + int r = send(sock, (char*)buffer + sofar, todo-sofar, 0); + if (r < 0){ + socketError = true; + printf("Could not write! %s\n", strerror(errno)); + return false; + } + sofar += r; } - return r; + return true; } bool DDV_read(void * buffer, int width, int count, int sock){ - bool r = (recv(sock, buffer, width*count, 0) == width*count); - if (!r){ - socketError = true; - printf("Could not read! %s\n", strerror(errno)); + int sofar = 0; + int todo = width*count; + while (sofar != todo){ + int r = recv(sock, (char*)buffer + sofar, todo-sofar, 0); + if (r < 0){ + socketError = true; + printf("Could not read! %s\n", strerror(errno)); + return false; + } + sofar += r; } - return r; + return true; }