views:

66

answers:

2

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

Socket.Select(readList, writeList, null, timeOut > 0 ? timeOut : 0);
+1  A: 

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

However, I haven't develop anything in WinSock but on Unix the way Select is implemented requires resetting the fd_set everytime Select returns. Maybe the same applies to WinSock implementation of Select also. If this is the case, your readList, writeList may have got corrupted after Select returned leading to the error you mentioned. Just a thought.

Aditya Sehgal
Good thoughts, but we do reinitialize the lists before calling `Select` each time. Thanks though.
David Pfeffer
oh..and the MSDN links also don't point to a kind of situation you might be having?
Aditya Sehgal
No, sorry. Thanks though.
David Pfeffer
A: 

It turns out the sockets were closed. That's a really dumb error for .NET to be generating though just because of a closed socket.

David Pfeffer