asio非boos版本使用

下载最新版 non_boost

linux下 ./configure --without-boost

make && make install

然后就可以使用了。

测试代码:

  1 #include "asio.hpp"
  2 #include <iostream>
  3 #include <vector>
  4 
  5 class TcpServer
  6 {
  7   public:
  8     TcpServer(int thread_num, int port, int buff_size)
  9     {
 10       pcontext_ = new asio::io_context(thread_num);
 11       pacc_ = new asio::ip::tcp::acceptor(*pcontext_, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), port));
 12       sock_ = new asio::ip::tcp::socket(pacc_->get_executor());
 13     }
 14 
 15     void start()
 16     {
 17       std::cout << "asio poll begin\n";
 18       pcontext_->run();
 19     }
 20   private:
 21     asio::io_context* pcontext_;
 22     asio::ip::tcp::acceptor* pacc_;
 23     asio::ip::tcp::socket* sock_;
 24     std::vector<unsigned char> buffer_;
 25     asio::ip::tcp::endpoint sender_;
 26 };
 27 int main()
 28 {
 29   TcpServer ts(1, 9000, 1024);
 30   ts.start();
 31   std::cout << "asio test" << std::endl;
 32 }

加断点调试

asio::io_context::run (this=0x61c040) at /usr/local/include/asio/impl/io_context.ipp:61

asio::detail::scheduler::run (this=0x61c0b0, ec=...) at /usr/local/include/asio/detail/impl/scheduler.ipp:189

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值