Bagikan melalui


IPEndPoint.Port Properti

Definisi

Mendapatkan atau mengatur nomor port titik akhir.

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

Nilai Properti

Nilai bilangan bulat dalam rentang MinPort untuk MaxPort menunjukkan nomor port titik akhir.

Pengecualian

Nilai yang ditentukan untuk operasi set kurang dari MinPort atau lebih besar dari MaxPort.

Contoh

Contoh berikut menggunakan Port properti untuk mengatur nomor port TCP dari 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

Berlaku untuk