locked
Dynamic Ports for Listener for TCP connection RRS feed

  • Question

  • I currently have a program that connects to a remote machine. On the remote machine is a listening program which waits for a client to connect and send information. Right now the program works fine but only if the ports are exactly the same on the client and listener.

    Dim client As New TcpClient(Me.strServer, port)

    and

    server = New TcpListener(Me.objIPAddress, port)

    The port parameter must be the same at all times. Is there a way to make the listener just wait for a connection without having the port be specified? Or possibly a way to use a proxy in the case that the client side port is blocked somehow... Any help would be appreciated.
    Thursday, May 31, 2007 7:39 PM

Answers

  • No, that's not how TCP works.  You'll have to agree on a common port number.  It also has to be unique, no other socket on your PC could be listening on the same port number.
    Saturday, June 2, 2007 3:29 PM