|
Net++
A class-based C++ encapsulation over the POSIX Sockets API
|
Accepts connections and assigns a dedicated TCPConnection object. More...
#include <tcp.hpp>
Public Member Functions | |
| Acceptor (std::string port, int32_t domain) | |
| Constructor for the Acceptor object. | |
| ~Acceptor () | |
| Destructor of the Acceptor object. | |
| Acceptor (Acceptor &&other) noexcept | |
| Copy constructor for the Acceptor object. | |
| Acceptor & | operator= (Acceptor &&other) noexcept |
| Copy operator for the Acceptor object. | |
| void | bind () const |
| Binds the socket handle to the host machine's address. | |
| void | listen () const |
| Starts listening on the socket for incoming connections. | |
| Connection::connection_ptr | accept () const |
| Accepts incoming connections synchronously. | |
Accepts connections and assigns a dedicated TCPConnection object.
Encapsulates a listening socket
| tcp::Acceptor::Acceptor | ( | std::string | port, |
| int32_t | domain | ||
| ) |
Constructor for the Acceptor object.
Creates a TCP connection with the capability to listen and accept connections on the given port.
| port | The port in string format |
| tcp::Acceptor::~Acceptor | ( | ) |
Destructor of the Acceptor object.
Closes the underlying socket handle.
|
noexcept |
Copy constructor for the Acceptor object.
Moves the underlying socket handle and port from the source object and invalidates the source object
| Connection::connection_ptr tcp::Acceptor::accept | ( | ) | const |
Accepts incoming connections synchronously.
Makes a call to the POSIX accept and creates a shared pointer to a tcp::Connection object with the resulting file descriptor
| void tcp::Acceptor::bind | ( | ) | const |
Binds the socket handle to the host machine's address.
Handles getaddrinfo() in passive mode and makes a call to the POSIX bind. See "$ man 2 bind"
| void tcp::Acceptor::listen | ( | ) | const |
Starts listening on the socket for incoming connections.
Copy operator for the Acceptor object.
Closes any open sockets, moves the socket handle and port from the source object, and invalidates the source object