client端代码
#include <iostream> #include <boost/asio.hpp> #include <boost/bind.hpp> #include <boost/shared_ptr.hpp> using boost::asio::ip::tcp; class client { public: client(boost::asio::io_service& io_service,tcp::endpoint& endpoint) : socket(io_service)//这里就把socket实例化了 { //连接服务端 connect socket.async_connect(endpoint, boost::bind(&client::handle_connect,this,boost::asio::placeholders::error) ); memset(getBuffer,'