Asynchronously waits until a socket is read / write in Asio

I want to do the following with Boost Asio. I have a socket and I want to register a callback for the call when the data is read / write on the socket, but I do not want it to actually read / write. Basically, I need it to be like async_read_some / async_write_some , except that the actual read and write are not executed.

I need this because I use an external library with my own read and write function, which requires a socket descriptor as an input parameter, and I want to use this library asynchronously.

+7
source share
1 answer

You are looking for reactor operation. They can be obtained by providing boost::asio::null_buffers for asynchronous operations. Reactor-style operations can be useful for integration with third-party libraries, the use of shared memory pools, etc. The Boost.Asio documentation is a non-blocking example that illustrates how to integrate with libraries that want to read and write directly to the socket.

+8
source

All Articles