-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.h
More file actions
61 lines (47 loc) · 1.09 KB
/
Server.h
File metadata and controls
61 lines (47 loc) · 1.09 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright ©2017 NagraFrance
*/
#ifndef _SERVER_H_
#define _SERVER_H_
#include <cstdlib>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
using namespace boost::asio;
using namespace boost::system;
using namespace boost::asio::ip;
namespace cpad
{
class session
{
public:
session(io_service& io_service);
tcp::socket& socket(void);
void start(void);
private:
void dump_data(size_t size);
void handle_read(const error_code& error,
size_t bytes_transferred);
void handle_write(const error_code& error);
tcp::socket m_socket;
enum {
max_length = 1024
};
char m_data[max_length];
};
class server
{
public:
server(io_service& io_svc, short port);
private:
void start_signal_wait(void);
void handle_signal_wait(void);
void start_accept(void);
void handle_accept(session* new_session,
const error_code& error);
io_service& m_io_svc;
boost::asio::signal_set m_signal;
tcp::acceptor m_acceptor;
};
} // namespace cpad
#endif /* !_SERVER_H_ */