IRSOL
C++ code implementing socket server for interacting with Baumer camera.
acceptor.hpp
Go to the documentation of this file.
1
14#pragma once
15
17#include "irsol/types.hpp"
18
19#include <atomic>
20#include <functional>
21#include <memory>
22
23namespace irsol {
24namespace server {
25namespace internal {
26
40
49{
50public:
57
64 void run();
65
71 void stop();
72
79 std::string error() const;
80
85 bool isOpen() const;
86
87private:
93 std::atomic<bool> m_running{false};
94
99
104
109
114};
115
116} // namespace internal
117} // namespace server
118} // namespace irsol
Accepts incoming TCP connections and triggers a callback for each new client.
Definition acceptor.hpp:49
OnNewClientCallback_t m_onNewClientCallback
Callback to handle accepted client connections.
Definition acceptor.hpp:103
const irsol::types::port_t m_port
Port on which to accept incoming TCP connections.
Definition acceptor.hpp:98
irsol::types::acceptor_t m_acceptor
TCP acceptor socket bound to m_port.
Definition acceptor.hpp:108
std::atomic< bool > m_running
Flag indicating whether the acceptor should continue running.
Definition acceptor.hpp:93
bool isOpen() const
Checks if the acceptor is actively listening.
Definition acceptor.cpp:27
std::string error() const
Gets the current error message, if any.
Definition acceptor.cpp:20
void run()
Starts the accept loop.
Definition acceptor.cpp:44
irsol::types::connection_result_t m_isOpen
Result of attempting to bind and open the acceptor socket.
Definition acceptor.hpp:113
std::function< void(irsol::types::client_id_t, irsol::types::socket_t &&)> OnNewClientCallback_t
Callback function for handling new client connections.
Definition acceptor.hpp:39
std::string client_id_t
Represents a unique client identifier. Typically used to identify connected clients by string IDs.
Definition types.hpp:55
sockpp::result<> connection_result_t
Result type representing success or failure of a socket operation.
Definition types.hpp:95
uint16_t port_t
Represents a network port number. Typically used to specify TCP or UDP ports.
Definition types.hpp:48
sockpp::tcp_socket socket_t
Alias for a TCP socket.
Definition types.hpp:87
sockpp::tcp_acceptor acceptor_t
Alias for the TCP server socket acceptor type.
Definition types.hpp:63
Declaration of the ClientSession class.
Core type definitions for networking, time handling, and protocol values used throughout the irsol li...