StreamSocketListenerInformation.LocalPort | localPort property

Applies to Windows and Windows Phone

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

Syntax


var localPort = streamSocketListenerInformation.localPort;

Property value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The local TCP port number or service name.

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.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Networking.Sockets
Windows::Networking::Sockets [C++]

Metadata

Windows.winmd

DLL

Windows.Networking.dll

Capabilities

ID_CAP_NETWORKING [Windows Phone]

See also

Other resources
How to use advanced socket controls (HTML)
How to use advanced socket controls (XAML)
Reference
BindEndpointAsync
BindServiceNameAsync
StreamSocketListener
StreamSocketListenerInformation

 

 

Show:
© 2014 Microsoft