StreamSocketListenerInformation.LocalPort Property

Definition

Get the local TCP port number associated with a StreamSocketListener object.

public:
 property Platform::String ^ LocalPort { Platform::String ^ get(); };
winrt::hstring LocalPort();
public string LocalPort { get; }
var string = streamSocketListenerInformation.localPort;
Public ReadOnly Property LocalPort As String

Property Value

String

Platform::String

winrt::hstring

The local TCP port number or service name.

Windows requirements

App capabilities
ID_CAP_NETWORKING [Windows Phone]

Remarks

The LocalPort property represents the local TCP port number bound to the StreamSocketListener object.

An app can set the local service name or TCP port number by calling the BindServiceNameAsync or BindEndpointAsync method on the StreamSocketListener. These methods will bind the StreamSocketListener object to the specific local IP address and local UDP port number. After the bind completes, the LocalPort property contains the local TCP port number that the local service name resolved to.

The BindEndpointAsync method will bind the socket to a specific IP address or hostname and a specific local TCP port number or service name .

The BindServiceNameAsync method will bind the socket to the specific TCP port number or service name. The system will determine the local IP address or hostname to associate with a StreamSocketListener object.

After the initial bind operation completes, LocalPort is read only and cannot be changed by calling the BindServiceNameAsync or BindEndpointAsync method again. The LocalPort property can be used at any time to get the local TCP port number associated with a StreamSocketListener object.

Applies to

See also