Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-11 15:13:55


--- christopher baus <christopher_at_[hidden]> wrote:
> 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?

The intention is that you use boost::bind to create the
appropriate function object:

void connect_handler(const boost::asio::error& error,
  boost::asio::stream_socket* socket)
  if (!error)

int main()
  boost::asio::stream_socket* socket = ...;
      boost::bind(connect_handler, _1, socket)

  // Or if you don't want to remember the index of the
  // arguments:
  // socket->async_connect(endpoint,
  // boost::bind(connect_handler,
  // boost::asio::placeholders::error, socket));


Boost list run by bdawes at, gregod at, cpdaniel at, john at