IPEndPoint.Create(SocketAddress) 方法

定义

从套接字地址创建终结点。Creates an endpoint from a socket address.

public:
 override System::Net::EndPoint ^ Create(System::Net::SocketAddress ^ socketAddress);
public override System.Net.EndPoint Create (System.Net.SocketAddress socketAddress);
override this.Create : System.Net.SocketAddress -> System.Net.EndPoint
Public Overrides Function Create (socketAddress As SocketAddress) As EndPoint

参数

socketAddress
SocketAddress

用于终结点的 SocketAddressThe SocketAddress to use for the endpoint.

返回

EndPoint

使用指定套接字地址的 EndPoint 实例。An EndPoint instance using the specified socket address.

例外

socketAddress 的 AddressFamily 与当前实例的 AddressFamily 不相等。The AddressFamily of socketAddress is not equal to the AddressFamily of the current instance.

-或--or- socketAddress.Size < 8。socketAddress.Size < 8.

示例

下面的示例使用指定的 SocketAddress 来创建 IPEndPointThe following example uses the specified SocketAddress to create an IPEndPoint.

// Recreate the connection endpoint from the serialized information.
IPEndPoint^ endpoint = gcnew IPEndPoint( (__int64)0,0 );
IPEndPoint^ clonedIPEndPoint = dynamic_cast<IPEndPoint^>(endpoint->Create( socketAddress ));
Console::WriteLine( "clonedIPEndPoint: {0}", clonedIPEndPoint );
// 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());
' Recreate the connection endpoint from the serialized information.
Dim endpoint As New IPEndPoint(0, 0)
Dim clonedIPEndPoint As IPEndPoint = CType(endpoint.Create(socketAddress), IPEndPoint)
Console.WriteLine(("clonedIPEndPoint: " + clonedIPEndPoint.ToString()))

适用于

另请参阅