Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

How do I configure my own file descriptor or HANDLE in AFIO?

Sometimes you receive a file descriptor or HANDLE from a third party piece of code and you need to insert it as-in into AFIO for use. The solution to this is very simple:

  1. Subclass handle with a custom implementation for your file descriptor type. In particular, you probably will have custom close semantics (e.g. don't close, or invoke third party code to implement close).
  2. Instantiate your custom handle implementation, and pass it into async_file_io_dispatcher_base::adopt(). This will immediately convert your custom handle type into an async_io_op suitable for supplying to read(), write() etc.
  3. That's it, there is no more to it.

PrevUpHomeNext