#include #include #include #include #include using boost::asio::ip::tcp; typedef boost::shared_ptr socket_ptr; void client_session(socket_ptr); int main() { boost::asio::io_service io; //Here is a simple synchronous server:using boost::asio; tcp::endpoint ep( tcp::v4(), 2001); // listen on 2001 tcp::acceptor acc(io, ep); while ( true) { socket_ptr sock(new tcp::socket(io)); acc.accept(*sock); boost::thread (boost::bind(&client_session, sock)); std::cout<<"Start thread"<read_some(boost::asio::buffer(data)); if ( len > 0) write(*sock, boost::asio::buffer("ok", 2)); } }