Asio includes classes added to permit synchronous and asynchronous read and write operations to be performed on POSIX file descriptors, such as pipes, standard input and output, and various devices (but not regular files).
For example, to perform read and write operations on standard input and output, the following objects may be created:
posix::stream_descriptor in(my_io_service, ::dup(STDIN_FILENO)); posix::stream_descriptor out(my_io_service, ::dup(STDOUT_FILENO));
These are then used as synchronous or asynchronous read and write streams. This means the objects can be used with any of the read(), async_read(), write(), async_write(), read_until() or async_read_until() free functions.
posix::stream_descriptor, posix::basic_stream_descriptor, posix::stream_descriptor_service, Chat example (C++03), Chat example (C++11).
POSIX stream descriptors are only available at compile time if supported
by the target operating system. A program may test for the macro ASIO_HAS_POSIX_STREAM_DESCRIPTOR
to determine
whether they are supported.