Fix a networking problem when trying to send data to a disconnected socket

According to SDL docs, SDLNet_TCP_Send is blocking and if the returned
nubmer of bytes sent is less than expected, it's an error. Previous code
could trigger an infinite loop with the function returning zero and our
loop trying to send again and again.
This commit is contained in:
Tomasz Śniatowski 2009-05-18 16:39:34 +01:00
parent ad88be254f
commit 3fdfcef63a

View file

@ -407,7 +407,11 @@ static SOCKET_STATE send_buffer(TCPsocket sock, std::vector<char>& buf, int in_s
}
send_len = static_cast<int>(size - upto);
const int res = SDLNet_TCP_Send(sock, &buf[upto],send_len);
if (res < send_len) {
// according to http://www.libsdl.org/cgi/docwiki.cgi/SDLNet_TCP_Send
// if the return value is less than len, it's an error
return SOCKET_ERRORED;
}
if( res == send_len) {
if (!raw_data_only)