StreamSocketListenerInformation.LocalPort 屬性

定義

取得與 StreamSocketListener 物件相關聯的本機 TCP 埠號碼。

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

屬性值

String

Platform::String

winrt::hstring

本機 TCP 通訊埠號碼或服務名稱。

Windows 需求

應用程式功能
ID_CAP_NETWORKING [Windows Phone]

備註

LocalPort 屬性代表系結至 StreamSocketListener 物件的本機 TCP 通訊埠號碼。

應用程式可以在StreamSocketListener上呼叫BindServiceNameAsyncBindEndpointAsync方法,以設定本機服務名稱或 TCP 通訊埠號碼。 這些方法會將 StreamSocketListener 物件系結至特定的本機 IP 位址和本機 UDP 埠號碼。 系結完成後, LocalPort 屬性會包含本機服務名稱解析為的本機 TCP 通訊埠號碼。

BindEndpointAsync方法會將通訊端系結至特定的 IP 位址或主機名稱,以及特定的本機 TCP 通訊埠號碼或服務名稱。

BindServiceNameAsync方法會將通訊端系結至特定的 TCP 通訊埠號碼或服務名稱。 系統會決定要與 StreamSocketListener 物件建立關聯的本機 IP 位址或主機名稱。

初始系結作業完成之後,LocalPort 是唯讀的,無法藉由再次呼叫 BindServiceNameAsyncBindEndpointAsync 方法來變更。 LocalPort 屬性可以隨時用來取得與 StreamSocketListener 物件相關聯的本機 TCP 通訊埠號碼。

適用於

另請參閱