Maintaining a large number of open sockets in a C # application

I am writing a C # application where I want to support a large number of open sockets (tcp) and be able to respond to data coming from all of them. Now the normal thing (afaik) is to call BeginRead for all of them, but as far as I know, BeginRead spawns a stream and sits and waits for data in that stream, and I read that streams do not tend to scale very well when using many of them. Although I may be wrong in this, if this is the case, just tell me.

It will probably sound idiotic, but I want it to be able to support as many open socket connections as possible (as my / os machine allows), but still able to respond to data coming from any of them as quickly as possible, and using as little system resources as possible.

I thought about putting everything in a list and then starting one thread in a loop above them, checking for new data and acting on that new data (if any), although I "Think such a cycle will end that I will fry my processor (because there is nothing in this cycle). Is there any way (simple or not, I do not mind to delve into some more complex algorithms to solve this) that I can achieve this? Any help would be appreciated.

+3
source share

All Articles