1
Vote

System.InvalidOperationException in NetBaseServer

description

This issue is against the NetSockets version 1.2 source code (change set 47519 ).
 
The Start(IPAddress, int, int) method of class NetBaseServer has code that can result in a System.InvalidOperationException. The TcpListener member 'tcp' is instantiated, and then has Start() called on it. Immediately after Start() is called the ThreadedAccept method is started on a new thread. ThreadedAccept then calls tcp.AcceptTcpClient() which can cause the System.InvalidOperationException.
 
The problem is that tcp.Start() may not have finished by the time tcp.AcceptTcpClient() is called.
 
There are a number of possible solutions; one is to add a catch(InvalidOperationException) into method ThreadedAccept which simply calls continue.

comments