1. 程式人生 > >boost socket 用法

boost socket 用法

boost::asio::ip::tcp::socket sock_(io_service_);
sock_.open(boost::asio::ip::tcp::v4());
boost::asio::ip::tcp::endpoint endpoint_1(boost::asio::ip::tcp::v4(),20001);
boost::asio::ip::address addr = boost::asio::ip::address::from_string("127.0.0.1");
endpoint_1.address(addr);
boost::system::error_code err;
sock_.connect(endpoint_1, err);