SCP/TMXR: Fix to socket writes to return 0 bytes written as an expected condition when the output socket is full (EAGAIN or EWOULDBLOCK).

This commit is contained in:
Mark Pizzolato 2013-11-04 05:21:58 -08:00
parent 796cbd2796
commit 43f85d1f3a

View file

@ -1033,7 +1033,18 @@ return rbytes;
int32 sim_write_sock (SOCKET sock, char *msg, int32 nbytes)
{
return send (sock, msg, nbytes, 0);
int32 err, sbytes = send (sock, msg, nbytes, 0);
if (sbytes == SOCKET_ERROR) {
err = WSAGetLastError ();
if (err == WSAEWOULDBLOCK) /* no data */
return 0;
#if defined(EAGAIN)
if (err == EAGAIN) /* no data */
return 0;
#endif
}
return sbytes;
}
void sim_close_sock (SOCKET sock, t_bool master)