-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.hpp
More file actions
74 lines (54 loc) · 1.41 KB
/
server.hpp
File metadata and controls
74 lines (54 loc) · 1.41 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
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Created by JakoError on 2022/11/10.
//
#ifndef DBMS_SERVER_HPP
#define DBMS_SERVER_HPP
#include "DBMS.hpp"
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/intrusive/bstree.hpp>
#include <boost/lexical_cast.hpp>
#include <filesystem>
#include <utility>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
#include <iostream>
using namespace boost::asio;
using std::cout;
using std::endl;
using std::string;
using std::vector;
#ifndef MAX_CMD_SIZE
#define MAX_CMD_SIZE 1024
#endif //MAX_CMD_SIZE
#ifndef STR_LENGTH
#define STR_LENGTH 256
#endif //STR_LENGTH
namespace cppDBMS {
class DBMSServer {
private:
typedef boost::shared_ptr<boost::asio::ip::tcp::socket> socket_ptr;
int client_num = 0;
path dbms_path;
boost::mutex client_num_mutex;
boost::mutex sql_mutex;
//service instance
io_service ios;
ip::tcp::endpoint ep;
ip::tcp::acceptor acc;
void client_exit(const socket_ptr &sock);
void client_session(const socket_ptr &sock);
public:
DBMSServer(path dbms_path, ip::tcp protocal, ip::port_type port) :
dbms_path(std::move(dbms_path)),
ep(protocal, port),
acc(ios, ep) {
}
[[noreturn]] void start();
};
}
#endif //DBMS_SERVER_HPP