Nog een poging...
This commit is contained in:
parent
ed8008f956
commit
28373a9f6e
1 changed files with 22 additions and 10 deletions
|
@ -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;
|
||||||
|
while (sofar != todo){
|
||||||
|
int r = send(sock, (char*)buffer + sofar, todo-sofar, 0);
|
||||||
|
if (r < 0){
|
||||||
socketError = true;
|
socketError = true;
|
||||||
printf("Could not write! %s\n", strerror(errno));
|
printf("Could not write! %s\n", strerror(errno));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return r;
|
sofar += 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;
|
||||||
|
while (sofar != todo){
|
||||||
|
int r = recv(sock, (char*)buffer + sofar, todo-sofar, 0);
|
||||||
|
if (r < 0){
|
||||||
socketError = true;
|
socketError = true;
|
||||||
printf("Could not read! %s\n", strerror(errno));
|
printf("Could not read! %s\n", strerror(errno));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return r;
|
sofar += r;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue