public class SocketAddress
|
//Creates an IpEndPoint. IPAddress ipAddress = Dns.Resolve("www.contoso.com").AddressList[0]; IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, 11000); //Serializes the IPEndPoint. SocketAddress socketAddress = ipLocalEndPoint.Serialize(); //Verifies that ipLocalEndPoint is now serialized by printing its contents. Console.WriteLine("Contents of the socketAddress are: " + socketAddress.ToString()); //Checks the Family property. Console.WriteLine("The address family of the socketAddress is: " + socketAddress.Family.ToString()); //Checks the underlying buffer size. Console.WriteLine("The size of the underlying buffer is: " + socketAddress.Size.ToString());
ctor #1 | Overloaded:.ctor(AddressFamily family) Creates a new instance of the SocketAddress class for the given address family. |
ctor #2 | Overloaded:.ctor(AddressFamily family, int size) Creates a new instance of the SocketAddress class using the specified address family and buffer size. |
Family | Read-only Gets the AddressFamily enumerated value of the current SocketAddress. |
Item | Read-write Gets or sets the specified index element in the underlying buffer. |
Size | Read-only Gets the underlying buffer size of the SocketAddress. |
Equals | Overridden: Determines whether two Object instances are equal. |
GetHashCode | Overridden: Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString | Overridden: Returns information about the socket address. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public SocketAddress( |
family
public SocketAddress( |
family
size
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | The size parameter is less than 2. These two bytes are needed to store family and size. |
public AddressFamily Family {get;}
|
public byte this[int offset] {get; set;}
|
offset
Exception Type | Condition |
---|---|
IndexOutOfRangeException | The specified index does not exist in the buffer |
public int Size {get;}
|
comparand
~SocketAddress(); |
public override int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
public override string ToString(); |