-api-id | -api-type |
---|---|
P:Windows.Networking.Sockets.StreamSocketInformation.LocalPort |
winrt property |
Get the TCP port number associated with a StreamSocket.
The local TCP port number of service name.
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.
How to use advanced socket controls, LocalAddress, StreamSocket
ID_CAP_NETWORKING [Windows Phone]