我编写了一个服务器程序,有时会遇到以下异常。
System.Net.Sockets.SocketException: An operation was attempted on something that is not a socket
at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
at System.Net.Sockets.TcpListener..ctor(IPAddress localaddr, Int32 port)
在极少数情况下会出现此异常
代码段如下::
listener = new TcpListener(IPAddress.Loopback, port);
listener .Start(100);
任何人都可以帮我找到根本原因。我在许多论坛上搜索过,但未能得出明确的结论。为什么会发生这种情况。