IPEndPoint Constructor (IPAddress, Int32)
.NET Framework 2.0
Initializes a new instance of the IPEndPoint class with the specified address and port number.
Namespace: System.Net
Assembly: System (in system.dll)
Assembly: System (in system.dll)
public IPEndPoint ( IPAddress address, int port )
public function IPEndPoint ( address : IPAddress, port : int )
Parameters
- address
An IPAddress.
- port
The port number associated with the address, or 0 to specify any available port. port is in host order.
// Obtain the IP address from the list of IP addresses associated with the server. System::Collections::IEnumerator^ myEnum = host->AddressList->GetEnumerator(); while ( myEnum->MoveNext() ) { IPAddress^ address = safe_cast<IPAddress^>(myEnum->Current); IPEndPoint^ endpoint = gcnew IPEndPoint( address,port ); tempSocket = gcnew Socket( endpoint->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); tempSocket->Connect( endpoint ); if ( tempSocket->Connected ) { // Display the endpoint information. displayEndpointInfo( endpoint ); // Serialize the endpoint to obtain a SocketAddress object. serializedSocketAddress = serializeEndpoint( endpoint ); break; } else continue; }
// 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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.