う、動いてる…
#include <iostream> #include <string> #define _WIN32_WINNT 0x0501 #include <boost/bind.hpp> #include <boost/asio.hpp> using namespace std; using boost::bind; using boost::asio::io_service; using boost::asio::ip::tcp; using boost::system::error_code; void echo(tcp::acceptor *acceptor, tcp::iostream *s, const error_code &e) { string msg; *s >> msg; *s << msg << endl; acceptor->async_accept(*(*s).rdbuf(), bind(echo, acceptor, s, _1)); } int main() { io_service io; tcp::iostream s; tcp::acceptor acceptor(io, tcp::endpoint(tcp::v4(), 18080)); acceptor.async_accept(*s.rdbuf(), bind(echo, &acceptor, &s, _1)); io.run(); return 0; }
echo()のacceptorとsを参照にしたらコンパイルできず。むー。