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
46
47
48
49
50
51
/*
 * =====================================================================================
 *
 *       Filename:  tcp_test.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年05月24日 09时40分14秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), lichao@aiotlink.com
 *   Organization:  
 *
 * =====================================================================================
 */
 
#include "tcp_connection.h"
#include "tcp_server.h"
#include "util.h"
#include <sys/ioctl.h>
 
//////////////////////
 
template <class C, class V>
void Erase(C &c, V &&v)
{
    c.erase(std::remove(c.begin(), c.end(), v), c.end());
}
 
BOOST_AUTO_TEST_CASE(TcpTest)
{
    const std::string bind_addr = "127.0.0.1";
    const std::string connect_addr = "127.0.0.1";
    const uint16_t port = 10000;
 
    TcpServer server(port);
    server.Start();
 
    boost::asio::io_context io;
 
    tcp::endpoint dest(ip::address::from_string(connect_addr), port);
    for (int i = 0; i < 10; ++i) {
        TcpRequest1::Create(io, dest, "client->server " + std::to_string(i));
    }
 
    io.run();
 
    printf("TcpTest\n");
}