void server::ConnectTo(const std::string& sPort) { tcp::resolver::query query("127.0.0.1", sPort); tcp::resolver::iterator iterator = resolver_.resolve(query); for(int ii=0;ii<5000;ii++) { chat_client* pNewChatClient = new chat_client(io_service_,iterator,ii); } }
client(boost::asio::io_service& io_service, const std::string& server) : resolver_(io_service) { conn = TCPConnection::create(io_service); tcp::resolver::query query(server, "daytime"); resolver_.async_resolve(query, boost::bind(&client::handle_resolve, this, boost::asio::placeholders::error, boost::asio::placeholders::iterator)); }
void connectImpl(const string& ip, int port) { deleteMe(); io_service = new boost::asio::io_service(); resolver = new tcp::resolver(*io_service); std::string val = boost::lexical_cast<std::string>(port); query = new tcp::resolver::query(ip.c_str(), val.c_str()); tcp::resolver::iterator endpoint_iterator = resolver->resolve(*query); socket = new tcp::socket(*io_service); boost::asio::connect(*socket, endpoint_iterator); }
int main() { tcp::resolver::query q{"theboostcpplibraries.com", "80"}; resolv.async_resolve(q, resolve_handler); ioservice.run(); }