Example #1
0
inline boost::system::error_code connect(
    boost::asio::ip::tcp::socket::lowest_layer_type& socket,
    boost::asio::ip::tcp::resolver& resolver,
    const url& u, boost::system::error_code& ec)
{
  // Create a query that corresponds to the url.
  std::ostringstream port_string;
  port_string << u.port();

  // Get a list of endpoints corresponding to the query.
  boost::asio::ip::tcp::resolver::results_type endpoints = resolver.resolve(u.host(), port_string.str(), ec);
  if (ec)
    return ec;

  // Try each endpoint until we successfully establish a connection.
  ec = boost::asio::error::host_not_found;
  boost::asio::connect(socket, endpoints, ec);
  if (ec)
    return ec;

  // Disable the Nagle algorithm on all sockets.
  ec = boost::system::error_code();
  socket.set_option(boost::asio::ip::tcp::no_delay(true), ec);
  return ec;
}
Example #2
0
void async_connect(boost::asio::ip::tcp::socket::lowest_layer_type& socket,
    boost::asio::ip::tcp::resolver& resolver, const url& u, Handler handler)
{
  std::ostringstream port_string;
  port_string << u.port();
  connect_coro<Handler>(handler, socket, resolver)(
      boost::system::error_code(), u.host(), port_string.str());
}
Example #3
0
acceptor reactor::listen(const url& url){
    return make_wrapper(pn_reactor_acceptor(pn_object(), url.host().c_str(), url.port().c_str(), 0));
}