IPEndPoint.Port 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置终结点的端口号。
public:
property int Port { int get(); void set(int value); };
public int Port { get; set; }
member this.Port : int with get, set
Public Property Port As Integer
属性值
介于 MinPort 到 MaxPort 之间的整数值,指示终结点的端口号。
例外
示例
以下示例使用 Port 属性设置 的 EndPointTCP 端口号。
void displayEndpointInfo( IPEndPoint^ endpoint )
{
Console::WriteLine( "Endpoint->Address : {0}", endpoint->Address );
Console::WriteLine( "Endpoint->AddressFamily : {0}", endpoint->AddressFamily );
Console::WriteLine( "Endpoint->Port : {0}", endpoint->Port );
Console::WriteLine( "Endpoint.ToString() : {0}", endpoint );
Console::WriteLine( "Press any key to continue." );
Console::ReadLine();
}
private static void displayEndpointInfo(IPEndPoint endpoint)
{
Console.WriteLine("Endpoint.Address : " + endpoint.Address);
Console.WriteLine("Endpoint.AddressFamily : " + endpoint.AddressFamily);
Console.WriteLine("Endpoint.Port : " + endpoint.Port);
Console.WriteLine("Endpoint.ToString() : " + endpoint.ToString());
Console.WriteLine("Press any key to continue.");
Console.ReadLine();
}
Private Shared Sub displayEndpointInfo(ByVal endpoint As IPEndPoint)
Console.WriteLine("Endpoint Address : " + endpoint.Address.ToString())
Console.WriteLine("Endpoint AddressFamily : " + endpoint.AddressFamily.ToString())
Console.WriteLine("Endpoint Port : " + endpoint.Port.ToString())
Console.WriteLine("Endpoint ToString() : " + endpoint.ToString())
Console.WriteLine("Press any key to continue.")
Console.ReadLine()
End Sub