简体   繁体   中英

How many concurrent connections can I have open at one time when using HttpWebRequest?

I am using asynchronous HttpWebRequest BeginGetResponse calls; the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM