开发者

Are Asynchronous Sockets in .net threadless?

From http://msdn.microsoft.com/en-us/library/bbx2eya8.aspx it looks like, that this type of sockets are using more than one thread, but from what i am thinking Asynchronous Sockets can and should run in single thread (or least limited number of threads) , since they are just callbacks from state machine which works like smart scheduler.

My question is: Does asynchronous sockets spawns as many threads as there are connections or is there some upper bound of how many threads are spawned, no matter how many connections application handl开发者_开发技巧es.


Yes and no. All the real work is done by the TCP/IP driver stack. Which has no trouble handling multiple incomplete IRP requests. When one of them completes, an APC is fired on a threadpool thread which in turn ends up calling your completion callback. The underlying operating system object is called an "I/O completion port", you can read more about it in this SDK article.


It says right in the link you provided that asynchronous sockets use the thread pool, so by definition they are limited to a certain number of threads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜