Export (0) Print
Expand All

IPEndPoint.Serialize Method

Serializes endpoint information into a SocketAddress instance.

[Visual Basic]
Overrides Public Function Serialize() As SocketAddress
[C#]
public override SocketAddress Serialize();
[C++]
public: SocketAddress* Serialize();
[JScript]
public override function Serialize() : SocketAddress;

Return Value

A SocketAddress instance containing the socket address for the endpoint.

Example

[Visual Basic, C#, C++] The following example uses the Serialize method to serialize endpoint information into a SocketAddress instance.

[Visual Basic] 
' 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


[C#] 
// 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;
}

[C++] 
// 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(S"Endpoint.Serialize() : {0}", socketAddress);

   Console::WriteLine(S"Socket->Family : {0}", __box(socketAddress->Family));
   Console::WriteLine(S"Socket->Size : {0}", __box(socketAddress->Size));

   Console::WriteLine(S"Press any key to continue.");
   Console::ReadLine();

   return socketAddress;
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

IPEndPoint Class | IPEndPoint Members | System.Net Namespace | EndPoint

Show:
© 2014 Microsoft