SocketAddress

Namespace: System.Net.Sockets

Represents a socket address. This class is an abstract base class.

Remarks

The SocketAddress class provides the functionality to represent a socket address. Socket addresses are used to specify network endpoints for socket operations. This class is abstract and is not intended for direct instantiation. Instead, derived classes like IPv4SocketAddress and IPv6SocketAddress provide concrete implementations for specific address families.

Instances of SocketAddress are typically created and managed by the .NET networking classes, such as Socket and EndPoint. You generally do not need to create SocketAddress objects directly unless you are implementing custom network protocols or working at a very low level.

Inheritance Hierarchy

System.Object
    System.Net.Sockets.SocketAddress

Derived Classes

System.Net.Sockets.IPv4SocketAddress
System.Net.Sockets.IPv6SocketAddress

Constructors

protected SocketAddress(AddressFamily family, int size)
Initializes a new instance of the SocketAddress class with the specified address family and size. This constructor is protected and intended for use by derived classes.
protected SocketAddress(AddressFamily family)
Initializes a new instance of the SocketAddress class with the specified address family. This constructor is protected and intended for use by derived classes.

Properties

public int Size { get; }
Gets the size of the socket address in bytes.
public AddressFamily Family { get; }
Gets the address family for this socket address.

Methods

public override bool Equals(object obj)
Determines whether the specified object is equal to the current object.
public override int GetHashCode()
Serves as the default hash function.
public override string ToString()
Returns a string that represents the current object.

See Also

System.Net.Sockets Namespace

System Namespace