5 #ifndef LIBFORB_BASE_SKELETON_HPP 6 #define LIBFORB_BASE_SKELETON_HPP 12 #include <forb/stream/socket.hpp> 21 using thread_list_t = std::vector<std::thread>;
32 std::thread _server_thread;
42 explicit base_skeleton(
int port,
int queue_size = 10) : _port(port), _queue_size(queue_size) {};
93 void accept_connection();
98 #endif //LIBFORB_BASE_SKELETON_HPP C++ wrapper of the Socket POSIX API, which uses IPv4 and blocking communication.
Definition: socket.hpp:28
virtual ~base_skeleton()=default
Virtual destructor.
static void call_thread_body(base_skeleton *impl, forb::streams::socket call_socket)
The body of the threads which will serve each call request.
Definition: base_skeleton.cpp:33
static void listen_thread_body(base_skeleton *impl)
The body of the server thread, which will block on accept calls and spawn other threads, one for each new request.
Definition: base_skeleton.cpp:19
Virtual class that represents a stream.
Definition: stream.hpp:69
This function implements a memcpy abstract that is valid also for volatile data.
Definition: base_skeleton.hpp:15
virtual void execute_call(call_id_t code, forb::streams::stream *callstream, forb::streams::stream *datastream)=0
Virtual method that implementations shall define to actually serve a request call.
base_skeleton & operator=(const base_skeleton &other)=delete
This class does not support copy assignment.
base_skeleton(int port, int queue_size=10)
Constructs a new skeleton object associated with the given port.
Definition: base_skeleton.hpp:42
The class from which any automatically generated skeleton will inherit.
Definition: base_skeleton.hpp:18
void start_server()
The object will spawn a new thread ans start accepting connection requests.
Definition: base_skeleton.cpp:94
void join_server()
Joins the server thread, waiting for it to terminate, which happens only in case of an error within t...
Definition: base_skeleton.cpp:103
uint16_t call_id_t
The type that will be used to transmit the call_id.
Definition: declarations.hpp:12