Handle socket errors on Windows, which does not return 0 when a socket is disconnected like Linux does
This commit is contained in:
parent
883a78ad9d
commit
e6aadc414b
2 changed files with 21 additions and 21 deletions
|
|
@ -252,7 +252,7 @@ void NetworkClient::ListenThreadFunction()
|
|||
//Read first byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[0], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ void NetworkClient::ListenThreadFunction()
|
|||
//Read second byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[1], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -280,7 +280,7 @@ void NetworkClient::ListenThreadFunction()
|
|||
//Read third byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[2], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -294,7 +294,7 @@ void NetworkClient::ListenThreadFunction()
|
|||
//Read fourth byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[3], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -315,7 +315,7 @@ void NetworkClient::ListenThreadFunction()
|
|||
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
if(tmp_bytes_read == 0)
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -337,7 +337,7 @@ void NetworkClient::ListenThreadFunction()
|
|||
|
||||
tmp_bytes_read = recv_select(client_sock, &data[bytes_read], header.pkt_size - bytes_read, 0);
|
||||
|
||||
if(tmp_bytes_read == 0)
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
//Read first byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[0], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
//Read second byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[1], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -366,7 +366,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
//Read third byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[2], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -380,7 +380,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
//Read fourth byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[3], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -401,7 +401,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
if(tmp_bytes_read == 0)
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
@ -423,7 +423,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
|
||||
tmp_bytes_read = recv_select(client_sock, &data[bytes_read], header.pkt_size - bytes_read, 0);
|
||||
|
||||
if(tmp_bytes_read == 0)
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue