StreamSocketInformation.LocalPort | localPort property

Get the TCP port number associated with a StreamSocket.

Syntax


public string LocalPort { get; }

Property value

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

The local TCP port number of service name.

Remarks

The LocalPort property represents the local TCP port number the StreamSocket object is bound to after a connection is established.

An app can set the local service name or TCP port number to use by calling the ConnectAsync(EndpointPair) or ConnectAsync(EndpointPair, SocketProtectionLevel) method on the StreamSocket. The connect operation will bind the socket to the specific local IP address and local UDP port number. After the bind or connect operation completes, the LocalPort property contains the IP address and the LocalPort property contains the local TCP port number that the local hostname and service name resolved to.

If the local service name or TCP port number passed to the ConnectAsync(EndpointPair) or ConnectAsync(EndpointPair, SocketProtectionLevel) method is an empty string or the ConnectAsync(HostName, String) or ConnectAsync(HostName, String, SocketProtectionLevel) method is called, the system will determine the local TCP port number to bind to the StreamSocket object.

Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Capabilities

ID_CAP_NETWORKING [Windows Phone]

Requirements (operating system)

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

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
LocalAddress
StreamSocket
StreamSocketInformation

 

 

Show:
© 2015 Microsoft