G
Guest
I am developing a network server application that will connect to around 200
clients. The client software is already developed so I have to work within
this constraint.
The server listens for connections from clients and establishes a socket
connection. The socket remains active until either the server or client is
shutdown.
The clients send data to the server when they have new data to send or when
a status request has been made by the server.
Most examples I have seen close the socket after the message is received or
the response is sent. How do I handle the situation where I have to keep the
sockets open and listen for more messages?
There are a couple of approaches I but I'm not sure which,if either, is the
best.
1. Use the Async sockets methods (BeginRead etc...) At the end of each
message I start a new BeginRead to wait for the next message. The problem I
see with this method is that it would require a thread for each client. The
upper limit for clients is around 200. Is it reasonable to have 200 threads?
2. Poll the sockets to see which have data available for reading using
..Available or .Select., then use the Async methods to read the data.
Any help is greatly appreciated.
clients. The client software is already developed so I have to work within
this constraint.
The server listens for connections from clients and establishes a socket
connection. The socket remains active until either the server or client is
shutdown.
The clients send data to the server when they have new data to send or when
a status request has been made by the server.
Most examples I have seen close the socket after the message is received or
the response is sent. How do I handle the situation where I have to keep the
sockets open and listen for more messages?
There are a couple of approaches I but I'm not sure which,if either, is the
best.
1. Use the Async sockets methods (BeginRead etc...) At the end of each
message I start a new BeginRead to wait for the next message. The problem I
see with this method is that it would require a thread for each client. The
upper limit for clients is around 200. Is it reasonable to have 200 threads?
2. Poll the sockets to see which have data available for reading using
..Available or .Select., then use the Async methods to read the data.
Any help is greatly appreciated.