Nog een poging...

This commit is contained in:
Thulinma 2010-11-08 01:14:23 +01:00
parent ed8008f956
commit 28373a9f6e

View file

@ -37,19 +37,31 @@ int DDV_Accept(int sock){
} }
bool DDV_write(void * buffer, int width, int count, int sock){ bool DDV_write(void * buffer, int width, int count, int sock){
bool r = (send(sock, buffer, width*count, 0) == width*count); int sofar = 0;
if (!r){ int todo = width*count;
socketError = true; while (sofar != todo){
printf("Could not write! %s\n", strerror(errno)); 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 DDV_read(void * buffer, int width, int count, int sock){
bool r = (recv(sock, buffer, width*count, 0) == width*count); int sofar = 0;
if (!r){ int todo = width*count;
socketError = true; while (sofar != todo){
printf("Could not read! %s\n", strerror(errno)); 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;
} }