lichao
2021-05-25 5d8aa35858eea622e0e8e4a1f111fd408c483a31
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
/*
 * =====================================================================================
 *
 *       Filename:  tcp_proxy.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年05月19日 15时04分55秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), lichao@aiotlink.com
 *   Organization:  
 *
 * =====================================================================================
 */
#ifndef TCP_PROXY_E1YJ92U5
#define TCP_PROXY_E1YJ92U5
 
#include "shm.h"
#include "tcp_common.h"
#include <atomic>
#include <thread>
 
class ShmSocket;
 
class TcpProxy
{
public:
    TcpProxy();
    ~TcpProxy();
    bool Start(bhome_shm::SharedMemory &shm);
    void Stop();
 
private:
    bool Send(const std::string &ip, int port, std::string &&content);
    std::unique_ptr<ShmSocket> local_;
 
    boost::asio::io_context io_context_;
    std::thread worker_;
    std::atomic<bool> run_;
};
 
#endif // end of include guard: TCP_PROXY_E1YJ92U5