Fixed socket code constantly throwing exceptions about non-blocking.
This commit is contained in:
committed by
Chris Forbes
parent
99eb3b046d
commit
8eb4782a49
@@ -44,6 +44,11 @@ namespace OpenRA.Server
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// NOTE(jsd): Poll the socket first to see if there's anything there.
|
||||||
|
// This avoids the exception with SocketErrorCode == `SocketError.WouldBlock` thrown
|
||||||
|
// from `socket.Receive(rx)`.
|
||||||
|
if (!socket.Poll(0, SelectMode.SelectRead)) break;
|
||||||
|
|
||||||
if (0 < (len = socket.Receive(rx)))
|
if (0 < (len = socket.Receive(rx)))
|
||||||
data.AddRange(rx.Take(len));
|
data.AddRange(rx.Take(len));
|
||||||
else
|
else
|
||||||
@@ -52,11 +57,12 @@ namespace OpenRA.Server
|
|||||||
server.DropClient(this);
|
server.DropClient(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SocketException e)
|
catch (SocketException e)
|
||||||
{
|
{
|
||||||
|
// NOTE(jsd): This should no longer be needed with the socket.Poll call above.
|
||||||
if (e.SocketErrorCode == SocketError.WouldBlock) break;
|
if (e.SocketErrorCode == SocketError.WouldBlock) break;
|
||||||
|
|
||||||
server.DropClient(this);
|
server.DropClient(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user