I need to connect to thousands of clients via TCP on a proprietary protocol in order to receive data cyclically. I need to write a .NET server application in C #.
The first attempt was to create for each tcp socket its own thread, which works, but requires a lot of CPU usage.
I found out that it would be better to use .NET threadpool. As far as I understand ( http://msdn.microsoft.com/en-us/library/ms973903.aspx ), I could use timers so that each socket receives data cyclically for a given period (for example, 1 second). This does not work for me, because the sockets expire after the connection has been opened, because large sockets are opened in front of it, which must be opened before open sockets are opened.
Another attempt is to use asynchronous callbacks. This will work for me, but I don't know how to get sockets to receive data cyclically.
source
share