0
点赞
收藏
分享

微信扫一扫

简易asio tcp server

日月同辉9908 2022-12-01 阅读 72


#include <iostream>
#include "boost/asio.hpp"
using namespace std;
using namespace boost::asio;
io_service G_IOS;

int main() {
ip::tcp::endpoint ep(ip::tcp::v4(), 2110);
ip::tcp::acceptor acceptor(G_IOS, ep);
while (true) {
ip::tcp::socket sock(G_IOS);
acceptor.accept(sock);
cout << "client addr = " << sock.remote_endpoint().address() << endl;
sock.write_some(buffer("hello asio"));
}

return 0;
}

 

举报

相关推荐

0 条评论