IPEndPoint.Port Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the port number of the endpoint.
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
Property Value
An integer value in the range MinPort to MaxPort indicating the port number of the endpoint.
Exceptions
Examples
The following example uses the Port property to set TCP port number of the EndPoint.
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
Applies to
التعاون معنا على GitHub
يمكن العثور على مصدر هذا المحتوى على GitHub حيث يمكنك أيضاً إضافة مشاكل وطلبات سحب ومراجعتها. للحصول على معلومات إضافية، اطلع على دليل المساهم لدينا.