C# IPEndPoint Create
Description
IPEndPoint Create
Creates an endpoint from a socket address.
Syntax
IPEndPoint.Create
has the following syntax.
public override EndPoint Create(
SocketAddress socketAddress
)
Parameters
IPEndPoint.Create
has the following parameters.
socketAddress
- The SocketAddress to use for the endpoint.
Returns
IPEndPoint.Create
method returns An EndPoint instance using the specified socket address.
Example
The following example uses the specified SocketAddress to create an IPEndPoint.
using System;/* w w w. j a va2 s . c om*/
using System.Net;
using System.Net.Sockets;
public class Example
{
public static void Main()
{
IPEndPoint hostIPEndPoint = new IPEndPoint(IPAddress.Parse("192.1.1.1"), 80);
SocketAddress socketAddress = hostIPEndPoint.Serialize();
// Recreate the connection endpoint from the serialized information.
IPEndPoint endpoint = new IPEndPoint(0,0);
IPEndPoint clonedIPEndPoint = (IPEndPoint) endpoint.Create(socketAddress);
Console.WriteLine("clonedIPEndPoint: " + clonedIPEndPoint.ToString());
}
}
The code above generates the following result.