This documentation is archived and is not being maintained.

IPEndPoint.IPEndPoint(IPAddress, Int32) Constructor

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

Namespace: System.Net
Assembly: System (in system.dll)

'Declaration
Public Sub New ( _
	address As IPAddress, _
	port As Integer _
)
'Usage
Dim address As IPAddress
Dim port As Integer

Dim instance As New IPEndPoint(address, port)
public IPEndPoint (
	IPAddress address, 
	int port
)
public function IPEndPoint (
	address : IPAddress, 
	port : int
)
Not applicable.

Parameters

address

An IPAddress.

port

The port number associated with the address, or 0 to specify any available port. port is in host order.

Exception typeCondition

ArgumentOutOfRangeException

port is less than MinPort.

-or-

port is greater than MaxPort.

-or-

address is less than 0 or greater than 0x00000000FFFFFFFF.

' Obtain the IP address from the list of IP addresses associated with the server.
Dim address As IPAddress
For Each address In host.AddressList
  Dim endpoint As New IPEndPoint(address, port)


  tempSocket = New Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)

  tempSocket.Connect(endpoint)

  If tempSocket.Connected Then
    ' Display the endpoint information.
    displayEndpointInfo(endpoint)
    ' Serialize the endpoint to obtain a SocketAddress object.
    serializedSocketAddress = serializeEndpoint(endpoint)
    Exit For

  End If

Next address


// Obtain the IP address from the list of IP addresses 
// associated with the server.
for (int iCtr = 0; iCtr < host.get_AddressList().length; iCtr++) {
    IPAddress address = host.get_AddressList()[iCtr];
    IPEndPoint endpoint = new IPEndPoint(address, port);
    tempSocket = new Socket(endpoint.get_AddressFamily(), 
        SocketType.Stream, ProtocolType.Tcp);
    tempSocket.Connect(endpoint);
    if (tempSocket.get_Connected()) {
        // Display the endpoint information.
        DisplayEndpointInfo(endpoint);
        // Serialize the endpoint to obtain a SocketAddress object.
        serializedSocketAddress = SerializeEndpoint(endpoint);
        break;    
    }
    else {
        continue;
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: