while(true)
{
foreach(TcpClient c in m_Clients)
if(c.NetworkStream.DataAvailable)
Process(c);
Sleep(5);
}
It ain't pretty. Is there a better way to do this? ~BenDilts( void );
.NET version of select()?
I'm using C# to write a server that can host several clients. I'm using TcpClient right now (which gives public access to its internal Socket class). The problem is that I can't figure out how to do a select() type statement on them with a timeout. Basically, I'm doing a loop like this:
The Socket class has a static Select() method. Does that work for you? (I've never played much with TcpClient).
However, Select() isn't the best way to deal with sockets in .NET. Read this article for a better solution.
However, Select() isn't the best way to deal with sockets in .NET. Read this article for a better solution.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement