-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession.h
35 lines (28 loc) · 825 Bytes
/
session.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
#ifndef HSV_SVESSION
#define HSV_SVESSION
#include <memory>
#include "asio.hpp"
using asio::ip::tcp;
class session
: public std::enable_shared_from_this<session>
{
public:
explicit session(asio::io_context& io_context);
~session(void);
void start();
void stop();
asio::ip::tcp::socket & getSocket();
private:
void doReceive();
void receiveHander(const std::error_code &ec, std::size_t length);
void doSend(std::size_t length);
void sendHander(const std::error_code& ec, std::size_t send_len);
private:
tcp::socket socket_;
asio::streambuf recv_buf_;
asio::streambuf send_buf_;
enum { recv_max_len = 16 };
char data_[recv_max_len];
std::string data = "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\nKeep-Alive: timeout=365, max=9000\r\nContent-Length: 13\r\n\r\nHello, world!";
};
#endif