1

I have a multithreaded Server which is running on TCP Sockets.

I have written this method to test for multiple threads

TcpClient[] ClientArray = new TcpClient[10000];
for(i = 0; i < 10000; i++)
{
     ClientArray[i] = new TcpClient();
     // connect is my connect method to connect to the server
     ClientArray[i].connect() 
}

Is this method correct or would there be a better method to test for simultaneous connections

2
  • Assuming the above is your client side test code, you appear to be creating 10,000 connections one after another (serially). It depends on how your server handles those connections as to what is getting tested. It would certainly show that the server can handle 10,000 connections. You might look at Parallel.For msdn.microsoft.com/en-us/library/dd460713.aspx
    – Dweeberly
    Oct 27, 2013 at 2:37
  • It looks like you're actually testing the TcpClient or TcpListener here. I wouldn't write tests for this. I would say it's enough to test your server logic with maybe two concurrent connection attempts. That should prove that your communication is working well and nothing is blocked.
    – Matthias
    Oct 27, 2013 at 3:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.