Export (0) Print
Expand All

IPEndPoint Constructor (Int64, Int32)

.NET Framework 1.1

Initializes a new instance of the IPEndPoint class with the specified address and port number.

[Visual Basic]
Public Sub New( _
   ByVal address As Long, _
   ByVal port As Integer _
)
[C#]
public IPEndPoint(
   long address,
 int port
);
[C++]
public: IPEndPoint(
   __int64 address,
 int port
);
[JScript]
public function IPEndPoint(
   address : long,
 port : int
);

Parameters

address
The IP address of the Internet host.
port
The port number associated with the address, or 0 to specify any available port.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException port is less than MinPort.

-or-

port is greater than MaxPort.

-or-

address is less than 0 or greater than 0x00000000FFFFFFFF.

Example

[Visual Basic, C#, C++] The following example uses the specified IP address and port number to create an IPEndPoint.

[Visual Basic] 
Dim hostIPAddress1 As IPAddress = Dns.Resolve(hostString1).AddressList(0)
Dim hostIPEndPoint As New IPEndPoint(hostIPAddress1, 80)
Console.WriteLine((ControlChars.Cr + "IPEndPoint information:" + hostIPEndPoint.ToString()))
Console.WriteLine((ControlChars.Cr + ControlChars.Tab + "Maximum allowed Port Address :" + IPEndPoint.MaxPort.ToString()))
Console.WriteLine((ControlChars.Cr + ControlChars.Tab + "Minimum allowed Port Address :" + IPEndPoint.MinPort.ToString()))
Console.WriteLine((ControlChars.Cr + ControlChars.Tab + "Address Family :" + hostIPEndPoint.AddressFamily.ToString()))

[C#] 

        

            IPAddress hostIPAddress1 = (Dns.Resolve(hostString1)).AddressList[0];
            Console.WriteLine(hostIPAddress1.ToString());
            IPEndPoint hostIPEndPoint = new IPEndPoint(hostIPAddress1,80);
            Console.WriteLine("\nIPEndPoint information:" + hostIPEndPoint.ToString());
            Console.WriteLine("\n\tMaximum allowed Port Address :" + IPEndPoint.MaxPort);
            Console.WriteLine("\n\tMinimum allowed Port Address :" + IPEndPoint.MinPort);
            Console.WriteLine("\n\tAddress Family :" + hostIPEndPoint.AddressFamily);

[C++] 
IPAddress* hostIPAddress1 = (Dns::Resolve(hostString1))->AddressList[0];
Console::WriteLine(hostIPAddress1);
IPEndPoint* hostIPEndPoint = new IPEndPoint(hostIPAddress1,80);
Console::WriteLine(S"\nIPEndPoint information:{0}", hostIPEndPoint);
Console::WriteLine(S"\n\tMaximum allowed Port Address :{0}", __box(IPEndPoint::MaxPort));
Console::WriteLine(S"\n\tMinimum allowed Port Address :{0}", __box(IPEndPoint::MinPort));
Console::WriteLine(S"\n\tAddress Family :{0}", __box(hostIPEndPoint->AddressFamily));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

IPEndPoint Class | IPEndPoint Members | System.Net Namespace | IPEndPoint Constructor Overload List

Show:
© 2014 Microsoft