sockets: Simplify write function
parent
bd4c3a7286
commit
8bc25aa700
|
@ -133,28 +133,29 @@ WriteToRFBServer(rfbClient* client, const char *buf, unsigned int n)
|
||||||
// TODO: Dispatch events while waiting
|
// TODO: Dispatch events while waiting
|
||||||
while (i < n) {
|
while (i < n) {
|
||||||
j = write(client->sock, obuf + i, (n - i));
|
j = write(client->sock, obuf + i, (n - i));
|
||||||
if (j <= 0) {
|
if (j > 0) {
|
||||||
if (j < 0) {
|
i += j;
|
||||||
if (errno == EWOULDBLOCK || errno == EAGAIN) {
|
continue;
|
||||||
fds.fd = client->sock;
|
}
|
||||||
fds.events = POLLIN;
|
|
||||||
|
if (j == 0) {
|
||||||
if (poll(&fds, 1, -1) <= 0) {
|
rfbClientLog("write failed\n");
|
||||||
rfbClientErr("select\n");
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
|
||||||
j = 0;
|
if (errno != EWOULDBLOCK && errno != EAGAIN) {
|
||||||
} else {
|
rfbClientErr("write\n");
|
||||||
rfbClientErr("write\n");
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
|
||||||
} else {
|
fds.fd = client->sock;
|
||||||
rfbClientLog("write failed\n");
|
fds.events = POLLOUT;
|
||||||
return FALSE;
|
if (poll(&fds, 1, -1) <= 0) {
|
||||||
}
|
rfbClientErr("poll\n");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
i += j;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue