-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket_server.h
40 lines (35 loc) · 945 Bytes
/
socket_server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
// forward decl
struct pollfd;
#include "message_handler.h"
#include <string>
/**
* @brief Class to handle UDS socket server connections, reading, writing.
*/
class socket_server {
message_handler &m_message_handler;
int m_server_fd;
public:
/**
* @brief Create a socket_server object.
*
* @param msg_handler Broker for messages. Makes sense of raw data and calls callbacks.
*/
explicit socket_server(message_handler &msg_handler);
socket_server() = default;
virtual ~socket_server();
/**
* @brief Begin the socket server at path.
*
* @param path The path the server will listen on.
* @param[in|out] keep_running If false, stop serving.
*
*/
bool begin_serving(const std::string &path, bool &keep_running);
/**
* @brief Stops the UDS server.
*
* @return true on success, false otherwise.
*/
bool stop_serving();
};