B
Bruce
Hello
I am building a C# app that creates anywhere from 10 to 100
connections to a specified server and sends 1000s of TCP requests and
processes the responses. (it is a stress tool)
I planned to create a Socket object for each connection and do a
BeginReceive on each socket to handle the responses. (it is clean and
I can avoid the hassles of managing my own threads)
My question is, will this scale well? Or is there a more efficient way
to achieve this? (like having a single dedicated thread reading from
all socket streams and queueing the data to be processed by another
thread)
my code:
for(int i = 0; i < numberOfConnections; i++) {
Socket s = new Socket(.....);
s.Connect(serverEndpoint);
GetResponse(s);
}
GetResponse(Socket s) {
s.BeginReceive(...new AsyncCallback(OnReceived)...);
}
OnReceived(IAsyncResult ar) {
s.EndReceive();
GetResponse(s);
}
Send() {
<randomly chosen so\cket>.Send(...);
}
Thanks
Bruce
I am building a C# app that creates anywhere from 10 to 100
connections to a specified server and sends 1000s of TCP requests and
processes the responses. (it is a stress tool)
I planned to create a Socket object for each connection and do a
BeginReceive on each socket to handle the responses. (it is clean and
I can avoid the hassles of managing my own threads)
My question is, will this scale well? Or is there a more efficient way
to achieve this? (like having a single dedicated thread reading from
all socket streams and queueing the data to be processed by another
thread)
my code:
for(int i = 0; i < numberOfConnections; i++) {
Socket s = new Socket(.....);
s.Connect(serverEndpoint);
GetResponse(s);
}
GetResponse(Socket s) {
s.BeginReceive(...new AsyncCallback(OnReceived)...);
}
OnReceived(IAsyncResult ar) {
s.EndReceive();
GetResponse(s);
}
Send() {
<randomly chosen so\cket>.Send(...);
}
Thanks
Bruce