I'm using Aync socket call BeginReceive, I'm worried that this is using the threadPool and having 50 or more open sockets would cause the threadpool to be depleted, thus use a single thread for posting events back to the receive,transmit,connect tasks using select, but I want the thread to gracefully be aborted, is it possible to use select to wait for a event, ie ManualRest, I'm trying to port the C++ code to C# that can map Socket handles to Events then use WaitForMultipleEvents for exit event and socket events...

Sockets WaitForAny
anku
I was looking at the difference between IOCompletion threads and the threadpool, so async socket calls use the IOCompletion method not the threadpool
But lets say I don't want to use Async and use the ole Socket.Select and a single thread to process all sockets using a simple thread. Is there a way to use a Socket.Select and a WaitForAny, for example a ManualEvent for exit and the rest socket events
josephxxv
there is no one to one correspondence between an Async call and a thread pool thread. It is entirely possible that based on the timing of the calls the same thread serves one or more sockets. Thus the thread calling the begin receive's delegate on Socket 1 can the the same thread that calls begin Send's delegate on Socket 2
So in general I think the threadpool low situations does not arise. However if you block in your callbacks and don't return the thread to thread pool there will be a problem.
Thats why you should do least possible in your callbacks
kingofrain