forked from sorokin/echo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecho_server.h
More file actions
45 lines (35 loc) · 822 Bytes
/
echo_server.h
File metadata and controls
45 lines (35 loc) · 822 Bytes
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
41
42
43
44
45
#ifndef ECHO_SERVER_H
#define ECHO_SERVER_H
#include <map>
#ifdef __APPLE__
#include "socket_apple.h"
#else
#include "socket.h"
#endif
struct echo_server
{
struct connection
{
connection(echo_server* parent);
void try_read();
void try_write();
void process(bool read);
private:
echo_server* parent;
client_socket socket;
timer_element timer;
size_t start_offset;
size_t end_offset;
char buf[1500];
};
echo_server(epoll& ep);
echo_server(epoll& ep, ipv4_endpoint const& local_endpoint);
ipv4_endpoint local_endpoint() const;
private:
void on_new_connection();
private:
epoll& ep;
server_socket ss;
std::map<connection*, std::unique_ptr<connection>> connections;
};
#endif // ECHO_SERVER_H