2 / Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
8 [section:windows Windows-Specific Functionality]
10 [link boost_asio.overview.windows.stream_handle Stream-Oriented HANDLEs]
12 [link boost_asio.overview.windows.random_access_handle Random-Access HANDLEs]
14 [link boost_asio.overview.windows.object_handle Object HANDLEs]
16 [section:stream_handle Stream-Oriented HANDLEs]
18 Boost.Asio contains classes to allow asynchronous read and write operations to be
19 performed on Windows `HANDLE`s, such as named pipes.
21 For example, to perform asynchronous operations on a named pipe, the following
22 object may be created:
24 HANDLE handle = ::CreateFile(...);
25 windows::stream_handle pipe(my_io_service, handle);
27 These are then used as synchronous or asynchronous read and write streams. This
28 means the objects can be used with any of the [link boost_asio.reference.read
29 read()], [link boost_asio.reference.async_read async_read()], [link
30 boost_asio.reference.write write()], [link boost_asio.reference.async_write
31 async_write()], [link boost_asio.reference.read_until read_until()] or [link
32 boost_asio.reference.async_read_until async_read_until()] free functions.
34 The kernel object referred to by the `HANDLE` must support use with I/O
35 completion ports (which means that named pipes are supported, but anonymous
36 pipes and console streams are not).
40 [link boost_asio.reference.windows__stream_handle windows::stream_handle],
41 [link boost_asio.reference.windows__basic_stream_handle windows::basic_stream_handle],
42 [link boost_asio.reference.windows__stream_handle_service windows::stream_handle_service].
46 Windows stream `HANDLE`s are only available at compile time when targeting
47 Windows and only when the I/O completion port backend is used (which is the
48 default). A program may test for the macro `BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE` to
49 determine whether they are supported.
53 [/-----------------------------------------------------------------------------]
55 [section:random_access_handle Random-Access HANDLEs]
57 Boost.Asio provides Windows-specific classes that permit asynchronous read and write
58 operations to be performed on HANDLEs that refer to regular files.
60 For example, to perform asynchronous operations on a file the following object
63 HANDLE handle = ::CreateFile(...);
64 windows::random_access_handle file(my_io_service, handle);
66 Data may be read from or written to the handle using one of the
67 `read_some_at()`, `async_read_some_at()`, `write_some_at()` or
68 `async_write_some_at()` member functions. However, like the equivalent
69 functions (`read_some()`, etc.) on streams, these functions are only required
70 to transfer one or more bytes in a single operation. Therefore free functions
71 called [link boost_asio.reference.read_at read_at()], [link
72 boost_asio.reference.async_read_at async_read_at()], [link boost_asio.reference.write_at
73 write_at()] and [link boost_asio.reference.async_write_at async_write_at()] have been
74 created to repeatedly call the corresponding [^[**]_some_at()] function until
75 all data has been transferred.
79 [link boost_asio.reference.windows__random_access_handle windows::random_access_handle],
80 [link boost_asio.reference.windows__basic_random_access_handle windows::basic_random_access_handle],
81 [link boost_asio.reference.windows__random_access_handle_service windows::random_access_handle_service].
85 Windows random-access `HANDLE`s are only available at compile time when
86 targeting Windows and only when the I/O completion port backend is used (which
87 is the default). A program may test for the macro
88 `BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE` to determine whether they are
93 [/-----------------------------------------------------------------------------]
95 [section:object_handle Object HANDLEs]
97 Boost.Asio provides Windows-specific classes that permit asynchronous wait operations
98 to be performed on HANDLEs to kernel objects of the following types:
100 * Change notification
103 * Memory resource notification
109 For example, to perform asynchronous operations on an event, the following
110 object may be created:
112 HANDLE handle = ::CreateEvent(...);
113 windows::object_handle file(my_io_service, handle);
115 The `wait()` and `async_wait()` member functions may then be used to wait until
116 the kernel object is signalled.
120 [link boost_asio.reference.windows__object_handle windows::object_handle],
121 [link boost_asio.reference.windows__basic_object_handle windows::basic_object_handle],
122 [link boost_asio.reference.windows__object_handle_service windows::object_handle_service].
126 Windows object `HANDLE`s are only available at compile time when targeting
127 Windows. Programs may test for the macro `BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE` to
128 determine whether they are supported.