Boost logo

Boost :

From: christopher baus (christopher_at_[hidden])
Date: 2005-12-11 13:49:16


Hi,

I'm currently trying to port an app from libevent to asio to test out the
library. I have a quick question. Why doesn't the
basic_stream_socket::async_connect handler pass a pointer to the socket?
Is it assumed that the handler is a stateful functor and keeps a pointer
to the socket?

I wanted to do the following

void connect_handler(const boost::asio::error& error)
{
  //
  //

  if (!error)
  {
    // Connect succeeded.
    // How do I get the connected socket here?
    // I want to call async_read_some like:
    // s->async_read_some(...);
  }
}

int main()
{
  boost::asio::demuxer demuxer;

  boost::asio::stream_socket* socket = new
boost::asio::stream_socket(demuxer);

  boost::asio::ipv4::address addr("127.0.0.1");
  socket->async_connect(boost::asio::ipv4::tcp::endpoint(80, addr),
connect_handler);

  demuxer.run();
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk