C# IPEndPoint Serialize

Description

IPEndPoint Serialize Serializes endpoint information into a SocketAddress instance.

Syntax

IPEndPoint.Serialize has the following syntax.


public override SocketAddress Serialize()

Returns

IPEndPoint.Serialize method returns A SocketAddress instance containing the socket address for the endpoint.

Example

The following example uses the Serialize method to serialize endpoint information into a SocketAddress instance.


using System;//w ww  .  j a  v  a2 s  . c  o  m
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();

        Console.WriteLine("Endpoint.Serialize() : " + socketAddress.ToString());

        Console.WriteLine("Socket.Family : " + socketAddress.Family);
        Console.WriteLine("Socket.Size : " + socketAddress.Size);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient