Socket.Select returns an error "An operation was attempted for something that is not a socket"

When I call Socket.Select with lists that are checked to contain only Socket objects, I sometimes get the error An operation was attempted on something that is not a socket . I can not find a pattern for occurrence.

 Socket.Select(readList, writeList, null, timeOut > 0 ? timeOut : 0); 
+8
c # networking sockets
source share
4 answers

It turns out the sockets are closed. This is a really stupid mistake for .NET, which is generated at least because of a closed socket.

+8
source share

I did a search on MSDN and got a couple of hits. See here and here.

However, I do not develop anything in WinSock, but on Unix, as implemented by Select , you need to reset fd_set each time Select . Perhaps the same applies to the implementation of WinSock Select. If so, your readList, writeList may get corrupted after the Select returns, leading to the error you specified. Just a thought.

+2
source share

I have this problem when the host firewall is on. I cannot add to disable my firewall due to the rules of my company. Thus, I added connection rules on my host computer for communication after that, it works fine.

0
source share

Restart MYSQL Service can help you ..

0
source share

All Articles