|
Boost : |
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-11 15:13:55
Hi,
--- 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)
{
s->async_read_some(...);
}
}
int main()
{
boost::asio::stream_socket* socket = ...;
...
socket->async_connect(endpoint,
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));
}
Cheers,
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk