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:
parent
ad88be254f
commit
3fdfcef63a
1 changed files with 5 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue