How many concurrent connections can I have open at one time when using HttpWebRequest?
I am using asynchronous HttpWebRequest BeginGetResponse calls; th开发者_JAVA百科e docs say that not closing the stream in the callback may result in running out of connections.
How many connections can I have before "running out"? I am using .NET 3.5.
Also, is there a socket connection pool in the CLR. If so, where is this documented?
How many? Depends on a lot of things; sockets share the I/O thread pool with all the other asynch I/O mechanisms.
A short if unhelpful answer is "lots". Unless you are creating a server of some sort you are highly unlikely to run out.
There isn't a socket connection pool as such, but there is an asynch I/O thread pool as you may have gleaned from the above. You may find instructive this blog post from Eric Eilebrecht, whereas a following post is about what happens next.
What you may not realise is that your router will play a big part in this. (And of course memory, internet connection speed etc.) It would be interesting to know what the theoretical maximum would be... Depending on your OS, you may need to do some tweaks to allow many connections.
精彩评论