none
Multiple TCP Listeners RRS feed

  • Question

  • Hi,

    I am starting multiple TCP listeners for 10 TCP ports. I get the first connection request successfully lets say for 1st port.

    I complete my Read/Write operation sucessfully and once done, I close the client reference and again wait for a new connection request.

    But I am not able to get the next connection request. In the client side, I can see that its sending me the request and but am unable to receive it.

    Moreover, this problem is coming only when the listener ports are more than 5. Till 4 ports am able to listen and connect again and again.

    I am using Listener.AcceptTcpClient method.

    P.S. Using BeginAcceptTcpClient is not a solutuon in my case, as I cant use asynchronous calls.

    Thanks.

    Runjhun.


    • Edited by Runjhun_A Monday, January 13, 2014 12:56 PM
    Friday, January 10, 2014 8:52 AM

Answers

  • Hi,

    Without the code, it is hard to tell something, maybe you can try to refer to the following code:

    System.Net.Sockets.TcpListener listener =   
                        new System.Net.Sockets.TcpListener();  
                      
                    // Block the listening thread until a new client connects.  
                    // If several clients try to connect, one will be served,  
                    // and the others will be queued.  
                    System.Net.Sockets.TcpClient client =   
                        listener.AcceptTcpClient();  
      
                    // Create a new thread which will handle the client, and  
                    // continue waiting for other clients.  
                    System.Threading.ThreadPool.QueueUserWorkItem(  
                        new System.Threading.WaitCallback(HandleClient));  
    

    And maybe you can try to use the NetTool to debug the network.

    For more information, please try to refer to:
    #NetTool - Web & Network Debugging Tool:
    http://nettool.sourceforge.net/ .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 15, 2014 3:04 AM
    Moderator