LocalPort

This property returns and sets the local port to use. For the client, this designates the local port from which to send data. For the server, this is the local port in which to listen.

Syntax

object.LocalPort [= long]

Parameters

object
Object expression that evaluates to a Winsock control.
object
Long value representing the local port.

Remarks

Port 0 often is used to establish connections between desktop computers dynamically. Specify port 0 if the application does not need a specific port, in which case the control will select a random port. After a connection is established, the local port specified in this property is used for the TCP/IP connection. For example, a client that wants to be called back by a server can use port 0 to procure a new (random) port number, which can then be passed to the remote computer.

The property contains the actual port that has been selected after your application invokes the Listen method.