-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
com-sockets.h
37 lines (27 loc) · 940 Bytes
/
com-sockets.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
#include "com.h"
#include "utils.h"
class com_client_sockets : public com_client
{
private:
const int fd { -1 };
public:
com_client_sockets(const int fd, std::atomic_bool *const stop);
virtual ~com_client_sockets();
std::string get_local_address() const override;
std::string get_endpoint_name() const override;
bool recv(uint8_t *const to, const size_t n) override;
bool send(const uint8_t *const from, const size_t n) override;
};
class com_sockets : public com
{
private:
std::string listen_ip;
const int listen_port;
int listen_fd { -1 };
public:
com_sockets(const std::string & listen_ip, const int listen_port, std::atomic_bool *const stop);
virtual ~com_sockets();
bool begin() override;
std::string get_local_address() const override { return myformat("%s:%d", listen_ip.c_str(), listen_port); }
com_client *accept() override;
};