客户端:
- #include
- #include
- #include
- #include
- #include
- using boost::asio::ip::tcp;
- using boost::asio::ip::address;
- class session: public boost::enable_shared_from_this {
- public:
- session(boost::asio::io_service &io_service, tcp::endpoint &endpoint)
- : io_service_(io_service), socket_(io_service), endpoint_(endpoint)
- {
- }
- void start() {
- socket_.async_connect(endpoint_,
- boost::bind(&session::handle_connect,
- shared_from_this(),
- boost::asio::placeholders::error));
- }
- private:
- void handle_connect(const boost::system::error_code &error) {
- if (error) {
- if (error.value() != boost::system::errc::operation_canceled) {
- std::cerr
关注打赏
立即登录/注册


微信扫码登录