/*
|
* =====================================================================================
|
*
|
* 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 "defs.h"
|
#include "node_center.h"
|
#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)
|
{
|
SharedMemory &shm = TestShm();
|
|
const std::string connect_addr = "127.0.0.1";
|
const uint16_t port = kBHCenterPort;
|
|
boost::asio::io_context io;
|
|
tcp::endpoint dest(ip::address::from_string(connect_addr), port);
|
MsgRequestTopic req;
|
req.set_topic("#center_query_procs");
|
req.set_data("");
|
auto head = InitMsgHead(GetType(req), "#test_proc", 1000000);
|
auto route = head.add_route();
|
route->set_mq_id(12345);
|
route->set_abs_addr(67890);
|
|
head.mutable_dest()->set_ip(connect_addr);
|
head.mutable_dest()->set_port(port);
|
head.mutable_dest()->set_mq_id(1000011);
|
head.mutable_dest()->set_abs_addr(10296);
|
|
auto request(MsgI::Serialize(head, req));
|
for (int i = 0; i < 1; ++i) {
|
LOG_DEBUG() << "request size: " << request.size();
|
TcpRequest1::Create(io, dest, request, DefaultSender(BHomeShm()));
|
}
|
|
io.run();
|
|
printf("TcpTest\n");
|
}
|