locked
Cant keep on listening to a port... RRS feed

  • Question

  • Hi!!

     

    i wanted some help...

    let me tell u what my program needs to do.. my server should listen to a port number say 5000. then search for another port on server pc which is free n redirect the client to connect to that port.. after redirecting.. my server shud again listen to that port.. port 5000. 

    now the problem m facing is.. that i cant get my program to keep on listening to port 5000. once i get a client connected. it doesnt look for another client connection... i hope u understand...

     

    can u suggest me some ways to make it happen...

    • Moved by Figo Fei Monday, October 25, 2010 3:14 AM (From:Visual C# Language)
    Friday, October 15, 2010 4:12 PM

All replies

  • I'm not sure what you want to accomplish. You can have as many clients as you wish (within hardware capacities) connected to your server on a specific port (say 5000) so there's no need to redirect them to a "free" port. A port is not "busy" if a connection has been made to it...

    You can deal with multiple clients by using a listening Socket that will Accept new connections (it will create a new Socket for each incoming request), or by using a TcpListener for slightly more comfortable use.

    Cristian.

    Friday, October 15, 2010 4:45 PM
  • how will i communicate with all the clients connecting to my server???

    1. a client connects to server at port 5000

    2. server finds a free port on server n notifies the client to connect to that port say 5010

    3. server then opens another app listening to port 5010 hence communicating with client connecting to 5010

    4. server then again listens to port 5000 and repeats this process for all the clients wanting to connect...

     

    this is how my program works...

    its running perfectly once.. but how can i repeat this cycle...

    Sunday, October 17, 2010 6:37 AM