IPEndPoint Port

In this chapter you will learn:

  1. How to Set Port for an IPEndPoint
  2. How to find out the Min Port and Max Port for IPEndPoint

Set Port for an IPEndPoint

using System;// j a v a  2s .co  m
using System.Net;


class MainClass
{
    public static void Main()
    {
        IPAddress test1 = IPAddress.Parse("192.168.1.1");
      IPEndPoint ie = new IPEndPoint(test1, 8000);
    
      ie.Port = 80;
      Console.WriteLine("The changed IPEndPoint value is: {0}", ie.ToString());
    
    }
}

The code above generates the following result.

IPEndPoint: MinPort and MaxPort

using System;/* jav  a  2  s  . c o m*/
using System.Net;


class MainClass
{
    public static void Main()
    {
      Console.WriteLine("The min port number is: {0}", IPEndPoint.MinPort);
      Console.WriteLine("The max port number is: {0}\n", IPEndPoint.MaxPort);
    }
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. Get Address Family, address and port from an IPEndPoint
Home » C# Tutorial » Network
Cookie
CredentialCache
HostEntry
IPHostEntry
IP address from host name
IPEndPoint from IPAddress
IPEndPoint Port
IPEndPoint properties
IPHostEntry
IP Address Parser
Predefined IP Address
NetworkCredential
Ping
Udp Client
Socket connection
Socket creation
Socket sendTo
TcpClient
TcpListener
UdpClient Receive
UdpClient Sending
Uri
WebClient
Response Headers
WebProxy
WebRequest