Boost logo

Boost Users :

Subject: Re: [Boost-users] Callback that calls a callback using boost::bind
From: Igor R (boost.lists_at_[hidden])
Date: 2011-10-02 03:54:36


> /// Smart Pointer
> typedef boost::shared_ptr<TcpServerSideConnection> SmartPtr;
>
>
> /// Callback function pointer type for TcpListener notification that
> our execution of
> /// TcpServerSideConnection::OnConnectionAccepted has completed
> typedef boost::function<void(TcpServerSideConnection::SmartPtr
> newConnection,
>                                 const boost::system::error_code &
> error)> ConnectionAcceptedListenerCallback;
>
>
> /// Callback function pointer type for TcpServerSideConnection
> notification of
> /// a TcpListener::Listen IO completion
> typedef boost::function<void(ConnectionAcceptedListenerCallback
> listenerCallback,
>                                 const boost::system::error_code &
> error)> ConnectionAcceptedCallback;
>
>
> TcpListener::SmartPtr me = boost::dynamic_pointer_cast<TcpListener,
> TcpBaseSocket>(shared_from_this());
>
>
> TcpServerSideConnection::ConnectionAcceptedListenerCallback
> listenerCallback =
>        boost::bind(&TcpListener::OnConnectionAccepted, me, _1, _2);
>
>
> TcpServerSideConnection::ConnectionAcceptedCallback
> acceptCompleteCallback =
>        boost::bind(&TcpServerSideConnection::OnConnectionAccepted,
> newConnection, listenerCallback, boost::asio::placeholders::error);
>
>
> acceptor_.async_accept(newConnection->GetSocket(),
> acceptCompleteCallback);
>
>
> Gives me a compile error in bind.hpp with 100s of pages.
>
>
> What am I doing wrong here?
> Does anyone have an example of a callback that callsback using boost::bind?

In general, I think you should use boost::protect around
"listenerCallback", but if you need help with exact expression, please
provide a self-contained sample.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net