IPEndPoint.Serialize 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将终结点信息序列化为 SocketAddress 实例。
public:
override System::Net::SocketAddress ^ Serialize();
public override System.Net.SocketAddress Serialize ();
override this.Serialize : unit -> System.Net.SocketAddress
Public Overrides Function Serialize () As SocketAddress
返回
一个 SocketAddress 实例,包含终结点的套接字地址。
示例
以下示例使用 Serialize 方法将终结点信息序列化到 SocketAddress 实例中。
// The serializeEndpoint function serializes the endpoint and returns the
// SocketAddress containing the serialized endpoint data.
SocketAddress^ serializeEndpoint( IPEndPoint^ endpoint )
{
// Serialize IPEndPoint details to a SocketAddress instance.
SocketAddress^ socketAddress = endpoint->Serialize();
// Display the serialized endpoint information.
Console::WriteLine( "Endpoint.Serialize() : {0}", socketAddress );
Console::WriteLine( "Socket->Family : {0}", socketAddress->Family );
Console::WriteLine( "Socket->Size : {0}", socketAddress->Size );
Console::WriteLine( "Press any key to continue." );
Console::ReadLine();
return socketAddress;
}
// The serializeEndpoint method serializes the endpoint and returns the
// SocketAddress containing the serialized endpoint data.
private static SocketAddress serializeEndpoint(IPEndPoint endpoint)
{
// Serialize IPEndPoint details to a SocketAddress instance.
SocketAddress socketAddress = endpoint.Serialize();
// Display the serialized endpoint information.
Console.WriteLine("Endpoint.Serialize() : " + socketAddress.ToString());
Console.WriteLine("Socket.Family : " + socketAddress.Family);
Console.WriteLine("Socket.Size : " + socketAddress.Size);
Console.WriteLine("Press any key to continue.");
Console.ReadLine();
return socketAddress;
}
' The serializeEndpoint method serializes the endpoint and returns the
' SocketAddress containing the serialized endpoint data.
Private Shared Function serializeEndpoint(ByVal endpoint As IPEndPoint) As SocketAddress
' Serialize IPEndPoint details to a SocketAddress instance.
Dim socketAddress As SocketAddress = endpoint.Serialize()
' Display the serialized endpoint information.
Console.WriteLine("Endpoint Serialize() : " + socketAddress.ToString())
Console.WriteLine("Socket Family : " + socketAddress.Family.ToString())
Console.WriteLine("Socket Size : " + socketAddress.ToString())
Console.WriteLine("Press any key to continue.")
Console.ReadLine()
Return socketAddress
End Function 'serializeEndpoint