C# IPEndPoint Port
Description
IPEndPoint Port
Gets or sets the port number of the endpoint.
Syntax
IPEndPoint.Port
has the following syntax.
public int Port { get; set; }
Example
Gets or sets the port number of the endpoint.
// ww w . ja va2 s . co m
using System;
using System.Net;
using System.Net.Sockets;
public class Example
{
public static void Main()
{
IPAddress hostIPAddress1 = (Dns.Resolve("google.com")).AddressList[0];
IPEndPoint endpoint = new IPEndPoint(hostIPAddress1,80);
Console.WriteLine("Endpoint.Address : " + endpoint.Address);
Console.WriteLine("Endpoint.AddressFamily : " + endpoint.AddressFamily);
Console.WriteLine("Endpoint.Port : " + endpoint.Port);
Console.WriteLine("Endpoint.ToString() : " + endpoint.ToString());
}
}
The code above generates the following result.