You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently encountered a strange bug when trying to close down a server.
I had set the MaxConnections to 1, and when trying to close the server, I disconnect each client, then try to stop the server.
Here is a code snippet:
foreach (var client in Server.GetClients())
{
Server.DisconnectClient(client);
}
if (Server.IsListening)
{
Server.Stop();
}
// Dispose the server to release underlying socket
Server.Dispose();
The issue is that the IsListening property gets set to false once the MaxConnections is reached, so my code never calls the Server.Stop method.
If I don't call Server.Stop, the underlying socket does not get released.
If I attempt to call Server.Stop when IsListening is false, it throws an exception.
I think that there should be 2 separate properties, IsListening and IsAcceptingConnections
The text was updated successfully, but these errors were encountered:
Update. It seems the behaviour is different when running on Linux compared to Windows. In Linux, the listener thread never restarts when max connections is reached, and then a client disconnects. This makes it impossible to shutdown the server.
I recently encountered a strange bug when trying to close down a server.
I had set the MaxConnections to 1, and when trying to close the server, I disconnect each client, then try to stop the server.
Here is a code snippet:
The issue is that the IsListening property gets set to false once the MaxConnections is reached, so my code never calls the Server.Stop method.
If I don't call Server.Stop, the underlying socket does not get released.
If I attempt to call Server.Stop when IsListening is false, it throws an exception.
I think that there should be 2 separate properties, IsListening and IsAcceptingConnections
The text was updated successfully, but these errors were encountered: