Class AbstractSocket

Inheritance Relationships

Derived Types

Class Documentation

class AbstractSocket

Represents an abstract socket for communication.

This class provides a common interface and functionality for socket operations. It manages the socket descriptor, local and remote addresses.

Subclassed by c2k::ClientSocket, c2k::ServerSocket

Public Types

using OsSocketHandle = int

Public Functions

inline std::optional<OsSocketHandle> os_socket_handle() const

Returns the operating system socket handle associated with the AbstractSocket.

If the socket descriptor has a value, it returns the value encapsulated in std::optional. Otherwise, it returns std::nullopt.

Returns:

The operating system socket handle as std::optional<OsSocketHandle>.

AddressInfo const &local_address() && = delete
inline AddressInfo const &local_address() const &

Get the local address information for the socket.

Returns:

A constant reference to the AddressInfo object containing the local address information.

AddressInfo const &remote_address() && = delete
inline AddressInfo const &remote_address() const &

Get the remote address information for the socket.

Returns:

A constant reference to the AddressInfo object representing the remote address information.

Protected Functions

explicit AbstractSocket(OsSocketHandle os_socket_handle)

Protected Attributes

UniqueValue<OsSocketHandle, void (*)(OsSocketHandle handle)> m_socket_descriptor