windows.qbk 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. [/
  2. / Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:windows Windows-Specific Functionality]
  8. [link boost_asio.overview.windows.stream_handle Stream-Oriented HANDLEs]
  9. [link boost_asio.overview.windows.random_access_handle Random-Access HANDLEs]
  10. [link boost_asio.overview.windows.object_handle Object HANDLEs]
  11. [section:stream_handle Stream-Oriented HANDLEs]
  12. Boost.Asio contains classes to allow asynchronous read and write operations to be
  13. performed on Windows `HANDLE`s, such as named pipes.
  14. For example, to perform asynchronous operations on a named pipe, the following
  15. object may be created:
  16. HANDLE handle = ::CreateFile(...);
  17. windows::stream_handle pipe(my_io_context, handle);
  18. These are then used as synchronous or asynchronous read and write streams. This
  19. means the objects can be used with any of the [link boost_asio.reference.read
  20. read()], [link boost_asio.reference.async_read async_read()], [link
  21. boost_asio.reference.write write()], [link boost_asio.reference.async_write
  22. async_write()], [link boost_asio.reference.read_until read_until()] or [link
  23. boost_asio.reference.async_read_until async_read_until()] free functions.
  24. The kernel object referred to by the `HANDLE` must support use with I/O
  25. completion ports (which means that named pipes are supported, but anonymous
  26. pipes and console streams are not).
  27. [heading See Also]
  28. [link boost_asio.reference.windows__stream_handle windows::stream_handle].
  29. [heading Notes]
  30. Windows stream `HANDLE`s are only available at compile time when targeting
  31. Windows and only when the I/O completion port backend is used (which is the
  32. default). A program may test for the macro `BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE` to
  33. determine whether they are supported.
  34. [endsect]
  35. [/-----------------------------------------------------------------------------]
  36. [section:random_access_handle Random-Access HANDLEs]
  37. Boost.Asio provides Windows-specific classes that permit asynchronous read and write
  38. operations to be performed on HANDLEs that refer to regular files.
  39. For example, to perform asynchronous operations on a file the following object
  40. may be created:
  41. HANDLE handle = ::CreateFile(...);
  42. windows::random_access_handle file(my_io_context, handle);
  43. Data may be read from or written to the handle using one of the
  44. `read_some_at()`, `async_read_some_at()`, `write_some_at()` or
  45. `async_write_some_at()` member functions. However, like the equivalent
  46. functions (`read_some()`, etc.) on streams, these functions are only required
  47. to transfer one or more bytes in a single operation. Therefore free functions
  48. called [link boost_asio.reference.read_at read_at()], [link
  49. boost_asio.reference.async_read_at async_read_at()], [link boost_asio.reference.write_at
  50. write_at()] and [link boost_asio.reference.async_write_at async_write_at()] have been
  51. created to repeatedly call the corresponding [^[**]_some_at()] function until
  52. all data has been transferred.
  53. [heading See Also]
  54. [link boost_asio.reference.windows__random_access_handle windows::random_access_handle].
  55. [heading Notes]
  56. Windows random-access `HANDLE`s are only available at compile time when
  57. targeting Windows and only when the I/O completion port backend is used (which
  58. is the default). A program may test for the macro
  59. `BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE` to determine whether they are
  60. supported.
  61. [endsect]
  62. [/-----------------------------------------------------------------------------]
  63. [section:object_handle Object HANDLEs]
  64. Boost.Asio provides Windows-specific classes that permit asynchronous wait operations
  65. to be performed on HANDLEs to kernel objects of the following types:
  66. * Change notification
  67. * Console input
  68. * Event
  69. * Memory resource notification
  70. * Process
  71. * Semaphore
  72. * Thread
  73. * Waitable timer
  74. For example, to perform asynchronous operations on an event, the following
  75. object may be created:
  76. HANDLE handle = ::CreateEvent(...);
  77. windows::object_handle file(my_io_context, handle);
  78. The `wait()` and `async_wait()` member functions may then be used to wait until
  79. the kernel object is signalled.
  80. [heading See Also]
  81. [link boost_asio.reference.windows__object_handle windows::object_handle].
  82. [heading Notes]
  83. Windows object `HANDLE`s are only available at compile time when targeting
  84. Windows. Programs may test for the macro `BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE` to
  85. determine whether they are supported.
  86. [endsect]
  87. [endsect]