-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.hpp
49 lines (33 loc) · 987 Bytes
/
client.hpp
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
//
// Created by JakoError on 2022/11/13.
//
#ifndef DBMS_CLIENT_HPP
#define DBMS_CLIENT_HPP
#include <boost/asio.hpp>
#include <string>
#include <utility>
#ifndef MAX_CMD_SIZE
#define MAX_CMD_SIZE 1024
#endif //MAX_CMD_SIZE
using namespace boost::asio;
using std::string;
namespace cppDBMS {
class DBMSClient {
private:
const string cmd_line = ">";
const int connect_try_times = 5;
public:
typedef boost::shared_ptr<boost::asio::ip::tcp::socket> socket_ptr;
string ip_address;
boost::asio::ip::port_type port;
io_service ios;
ip::tcp::endpoint ep;
socket_ptr sock;
void connect();
void start();
DBMSClient(string ipAddress, boost::asio::ip::port_type port) :
ip_address(std::move(ipAddress)), port(port),ep(ip::tcp::endpoint(ip::address::from_string(ip_address), port)),
sock(new ip::tcp::socket(ios)){}
};
}
#endif //DBMS_CLIENT_HPP