StreamSocketInformation.LocalPort 属性

定义

获取与 StreamSocket 关联的 TCP 端口号。

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

属性值

String

Platform::String

winrt::hstring

服务名称的本地 TCP 端口号。

Windows 要求

应用功能
ID_CAP_NETWORKING [Windows Phone]

注解

LocalPort 属性表示建立连接后 StreamSocket 对象绑定到的本地 TCP 端口号。

应用可以通过调用 StreamSocket 上的 ConnectAsync (EndpointPair) ConnectAsync (EndpointPair, SocketProtectionLevel) 方法来设置要使用的本地服务名称或 TCP 端口号。 连接操作会将套接字绑定到特定的本地 IP 地址和本地 UDP 端口号。 绑定或连接操作完成后,LocalPort 属性包含 IP 地址,LocalPort 属性包含本地主机名和服务名称解析到的本地 TCP 端口号。

如果传递给 ConnectAsync 的本地服务名称或 TCP 端口号 (EndpointPair) ConnectAsync (EndpointPair, SocketProtectionLevel) 方法为空字符串或 ConnectAsync (HostName、String) ConnectAsync (HostName、String、SocketProtectionLevel) 方法调用,系统将确定要绑定到 StreamSocket 对象的本地 TCP 端口号。

适用于

另请参阅