I have a service which as it's coming up invokes the Start() method on a TcpListener instance. This listener is using a port that is not common and not known to be used by any other services. Very very rarely for a span of minute or so it experiences an odd error. For a minute the service (which on failure restarts immediately) back to back crashes on the following exception:
SocketException
at System.Net.Sockets.Socket.DoBind(System.Net.EndPoint, System.Net.SocketAddress)
at System.Net.Sockets.Socket.Bind(System.Net.EndPoint)
at System.Net.Sockets.TcpListener.Start(Int32)
at MyTestServer.Server.StartListening()
With exception message as follows:
Only one usage of each socket address (protocol/network address/port) is normally permitted
This article suggests that I'm experience port exhaustion and that I should tweak the registry to modify timeout and port range values for WinSock. This is all good and well, but I only have (or expect to have) 50-100 clients connecting. How could I possibly run out of ports? Bots and port scanners?