![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
Accepts incoming TCP connections and triggers a callback for each new client. More...
#include <acceptor.hpp>
Public Member Functions | |
ClientSessionAcceptor (irsol::types::port_t port, OnNewClientCallback_t onNewClientCallback) | |
Constructs the acceptor. | |
void | run () |
Starts the accept loop. | |
void | stop () |
Stops the accept loop. | |
std::string | error () const |
Gets the current error message, if any. | |
bool | isOpen () const |
Checks if the acceptor is actively listening. | |
Private Attributes | |
std::atomic< bool > | m_running {false} |
Flag indicating whether the acceptor should continue running. | |
const irsol::types::port_t | m_port |
Port on which to accept incoming TCP connections. | |
OnNewClientCallback_t | m_onNewClientCallback |
Callback to handle accepted client connections. | |
irsol::types::acceptor_t | m_acceptor |
TCP acceptor socket bound to m_port. | |
irsol::types::connection_result_t | m_isOpen {} |
Result of attempting to bind and open the acceptor socket. | |
Accepts incoming TCP connections and triggers a callback for each new client.
The ClientSessionAcceptor listens on a given TCP port and forwards each accepted socket to the provided callback, enabling session initialization for each client.
Definition at line 48 of file acceptor.hpp.
irsol::server::internal::ClientSessionAcceptor::ClientSessionAcceptor | ( | irsol::types::port_t | port, |
OnNewClientCallback_t | onNewClientCallback | ||
) |
Constructs the acceptor.
port | TCP port to bind and listen on. |
onNewClientCallback | Function to call when a new client connects. |
Definition at line 11 of file acceptor.cpp.
std::string irsol::server::internal::ClientSessionAcceptor::error | ( | ) | const |
Gets the current error message, if any.
irsol::AssertionException | in case the acceptor it not in error mode. |
Definition at line 20 of file acceptor.cpp.
bool irsol::server::internal::ClientSessionAcceptor::isOpen | ( | ) | const |
Checks if the acceptor is actively listening.
Definition at line 27 of file acceptor.cpp.
void irsol::server::internal::ClientSessionAcceptor::run | ( | ) |
Starts the accept loop.
This method enters a blocking loop accepting client connections and invoking the callback for each. It is typically run in a dedicated thread.
Definition at line 44 of file acceptor.cpp.
void irsol::server::internal::ClientSessionAcceptor::stop | ( | ) |
Stops the accept loop.
Calling this method will cause run()
to return and stop accepting new connections.
Definition at line 33 of file acceptor.cpp.
|
private |
TCP acceptor socket bound to m_port.
Definition at line 108 of file acceptor.hpp.
|
private |
Result of attempting to bind and open the acceptor socket.
Definition at line 113 of file acceptor.hpp.
|
private |
Callback to handle accepted client connections.
Definition at line 103 of file acceptor.hpp.
|
private |
Port on which to accept incoming TCP connections.
Definition at line 98 of file acceptor.hpp.
|
private |
Flag indicating whether the acceptor should continue running.
Definition at line 93 of file acceptor.hpp.