Class Sockets
Defined in File sockets.hpp
Class Documentation
-
class Sockets
This class provides static member functions for creating server and client sockets.
Public Functions
-
~Sockets()
Public Static Functions
-
static inline ServerSocket create_server(AddressFamily const address_family, std::uint16_t const port, std::function<void(ClientSocket)> callback, [[maybe_unused]] Sockets const &key = instance())
Creates a server socket.
- Parameters:
address_family – The address family of the socket (Unspecified, Ipv4, Ipv6).
port – The port number to bind the socket to (0 to let the operating system choose a socket).
callback – The callback function to be executed when a client connects.
key – The Sockets instance to use. Cannot be user-provided.
- Returns:
The created ServerSocket object.
-
static ClientSocket create_client(AddressFamily address_family, std::string const &host, std::uint16_t port, [[maybe_unused]] Sockets const &key = instance())
Creates a client socket.
- Parameters:
address_family – The address family of the socket (Unspecified, Ipv4, Ipv6).
host – The hostname or IP address of the server to connect to.
port – The port number of the server to connect to.
key – The Sockets instance to use. Cannot be user-provided.
- Returns:
The created ClientSocket object.
-
~Sockets()