EchoTool icon indicating copy to clipboard operation
EchoTool copied to clipboard

Crashes in server mode

Open AndrewSav opened this issue 8 years ago • 0 comments

Server mode is intolerant to protocol violation. It is easy to crush the server by not playing by the rules. Ideally this should not happen. One misbehaving client should not crash the whole server.

To reproduce, start the program with following parameters:

/p tcp /s 7777

From another process run:

for (int i = 0; i < 100000; i++)
{
    TcpClient server = new TcpClient("127.0.0.1", 7777);
}

The server will crush within seconds. The exception is as follows:

System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
   at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   at EchoTool.Protocols.TcpEchoServer.ServerThread() in D:\scm\EchoTool\EchoTool\Protocols\TcpEchoServer.cs:line 115

AndrewSav avatar Apr 18 '16 04:04 AndrewSav