(or the equivalent system error).
Set to indicate what error occurred, if any. If the mode
is false
,
but the current value of non_blocking()
is true
,
this function fails with boost::asio::error::invalid_argument
,
as the combination does not make sense.
(Deprecated: Use native_handle_type.) The native representation of a descriptor.
typedef StreamDescriptorService::native_handle_type native_type;
Header: boost/asio/posix/basic_stream_descriptor.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the descriptor.
bool non_blocking() const; » more...
Sets the non-blocking mode of the descriptor.
void non_blocking( bool mode); » more... boost::system::error_code non_blocking( bool mode, boost::system::error_code & ec); » more...
Inherited from posix::basic_descriptor.
Gets the non-blocking mode of the descriptor.
bool non_blocking() const;
true
if the descriptor's
synchronous operations will fail with boost::asio::error::would_block
if they are unable to perform the requested operation immediately. If
false
, synchronous operations
will block until complete.
The non-blocking mode has no effect on the behaviour of asynchronous
operations. Asynchronous operations will never fail with the error boost::asio::error::would_block
.
Inherited from posix::basic_descriptor.
Sets the non-blocking mode of the descriptor.
void non_blocking( bool mode);
If true
, the descriptor's
synchronous operations will fail with boost::asio::error::would_block
if they are unable to perform the requested operation immediately.
If false
, synchronous
operations will block until complete.
Thrown on failure.
The non-blocking mode has no effect on the behaviour of asynchronous
operations. Asynchronous operations will never fail with the error boost::asio::error::would_block
.
Inherited from posix::basic_descriptor.
Sets the non-blocking mode of the descriptor.
boost::system::error_code non_blocking( bool mode, boost::system::error_code & ec);
If true
, the descriptor's
synchronous operations will fail with boost::asio::error::would_block
if they are unable to perform the requested operation immediately.
If false
, synchronous
operations will block until complete.
Set to indicate what error occurred, if any.
The non-blocking mode has no effect on the behaviour of asynchronous
operations. Asynchronous operations will never fail with the error boost::asio::error::would_block
.
Inherited from posix::descriptor_base.
(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the descriptor.
typedef implementation_defined non_blocking_io;
Implements the FIONBIO IO control command.
boost::asio::posix::stream_descriptor descriptor(io_service); ... boost::asio::descriptor_base::non_blocking_io command(true); descriptor.io_control(command);
Header: boost/asio/posix/basic_stream_descriptor.hpp
Convenience header: boost/asio.hpp
Move-assign a posix::basic_stream_descriptor
from another.
basic_stream_descriptor & operator=( basic_stream_descriptor && other);
This assignment operator moves a stream descriptor from one object to another.
The other posix::basic_stream_descriptor
object from which the move will occur.
Following the move, the moved-from object is in the same state as if constructed
using the basic_stream_descriptor(io_service&) constructor
.
Read some data from the descriptor.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers); » more... template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers, boost::system::error_code & ec); » more...
Read some data from the descriptor.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers);
This function is used to read data from the stream descriptor. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
One or more buffers into which the data will be read.
The number of bytes read.
Thrown on failure. An error code of boost::asio::error::eof
indicates that the connection was closed by the peer.
The read_some operation may not read all of the requested number of bytes.
Consider using the read
function if you need to
ensure that the requested amount of data is read before the blocking
operation completes.
To read into a single data buffer use the buffer
function as follows:
descriptor.read_some(boost::asio::buffer(data, size));
See the buffer
documentation for information on reading into multiple buffers in one
go, and how to use it with arrays, boost::array or std::vector.
Read some data from the descriptor.
template< typename MutableBufferSequence> std::size_t read_some( const MutableBufferSequence & buffers, boost::system::error_code & ec);
This function is used to read data from the stream descriptor. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
One or more buffers into which the data will be read.
Set to indicate what error occurred, if any.
The number of bytes read. Returns 0 if an error occurred.
The read_some operation may not read all of the requested number of bytes.
Consider using the read
function if you need to
ensure that the requested amount of data is read before the blocking
operation completes.
Inherited from posix::basic_descriptor.
Release ownership of the native descriptor implementation.
native_handle_type release();
This function may be used to obtain the underlying representation of the
descriptor. After calling this function, is_open()
returns false. The caller is responsible
for closing the descriptor.
All outstanding asynchronous read or write operations will finish immediately,
and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted
error.
Inherited from basic_io_object.
(Deprecated: Use get_service()
.) The service associated with the I/O
object.
service_type & service;
Available only for services that do not support movability.
Inherited from basic_io_object.
The type of the service that will be used to provide I/O operations.
typedef StreamDescriptorService service_type;
Header: boost/asio/posix/basic_stream_descriptor.hpp
Convenience header: boost/asio.hpp
Write some data to the descriptor.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers); » more... template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers, boost::system::error_code & ec); » more...
Write some data to the descriptor.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers);
This function is used to write data to the stream descriptor. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
One or more data buffers to be written to the descriptor.
The number of bytes written.
Thrown on failure. An error code of boost::asio::error::eof
indicates that the connection was closed by the peer.
The write_some operation may not transmit all of the data to the peer.
Consider using the write
function if you need to
ensure that all data is written before the blocking operation completes.
To write a single data buffer use the buffer
function as follows:
descriptor.write_some(boost::asio::buffer(data, size));
See the buffer
documentation for information on writing multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
Write some data to the descriptor.
template< typename ConstBufferSequence> std::size_t write_some( const ConstBufferSequence & buffers, boost::system::error_code & ec);
This function is used to write data to the stream descriptor. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
One or more data buffers to be written to the descriptor.
Set to indicate what error occurred, if any.
The number of bytes written. Returns 0 if an error occurred.
The write_some operation may not transmit all of the data to the peer.
Consider using the write
function if you need to
ensure that all data is written before the blocking operation completes.
The posix::descriptor_base
class is used as
a base for the posix::basic_stream_descriptor
class template
so that we have a common place to define the associated IO control commands.
class descriptor_base
|
Name |
Description |
|---|---|
|
IO control command to get the amount of data that can be read without blocking. |
|
|
(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the descriptor. |
|
Name |
Description |
|---|---|
|
Protected destructor to prevent deletion through this type. |
Header: boost/asio/posix/descriptor_base.hpp
Convenience header: boost/asio.hpp
IO control command to get the amount of data that can be read without blocking.
typedef implementation_defined bytes_readable;
Implements the FIONREAD IO control command.
boost::asio::posix::stream_descriptor descriptor(io_service); ... boost::asio::descriptor_base::bytes_readable command(true); descriptor.io_control(command); std::size_t bytes_readable = command.get();
Header: boost/asio/posix/descriptor_base.hpp
Convenience header: boost/asio.hpp
(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the descriptor.
typedef implementation_defined non_blocking_io;
Implements the FIONBIO IO control command.
boost::asio::posix::stream_descriptor descriptor(io_service); ... boost::asio::descriptor_base::non_blocking_io command(true); descriptor.io_control(command);
Header: boost/asio/posix/descriptor_base.hpp
Convenience header: boost/asio.hpp
Typedef for the typical usage of a stream-oriented descriptor.
typedef basic_stream_descriptor stream_descriptor;
|
Name |
Description |
|---|---|
|
IO control command to get the amount of data that can be read without blocking. |
|
|
The underlying implementation type of I/O object. |
|
|
A basic_descriptor is always the lowest layer. |
|
|
The native representation of a descriptor. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a descriptor. |
|
|
(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the descriptor. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native descriptor to the descriptor. |
|
|
Start an asynchronous read. |
|
|
Start an asynchronous write. |
|
|
Construct a basic_stream_descriptor without opening it. Construct a basic_stream_descriptor on an existing native descriptor.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native descriptor representation. |
|
|
Get the native descriptor representation. |
|
|
Gets the non-blocking mode of the native descriptor implementation. Sets the non-blocking mode of the native descriptor implementation. |
|
|
Gets the non-blocking mode of the descriptor. Sets the non-blocking mode of the descriptor. |
|
|
Move-assign a basic_stream_descriptor from another. |
|
|
Read some data from the descriptor. |
|
|
Release ownership of the native descriptor implementation. |
|
|
Write some data to the descriptor. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The posix::basic_stream_descriptor
class template
provides asynchronous and blocking stream-oriented descriptor functionality.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/posix/stream_descriptor.hpp
Convenience header: boost/asio.hpp
Default service implementation for a stream descriptor.
class stream_descriptor_service : public io_service::service
|
Name |
Description |
|---|---|
|
The type of a stream descriptor implementation. |
|
|
The native descriptor type. |
|
|
(Deprecated: Use native_handle_type.) The native descriptor type. |
|
Name |
Description |
|---|---|
|
Assign an existing native descriptor to a stream descriptor. |
|
|
Start an asynchronous read. |
|
|
Start an asynchronous write. |
|
|
Cancel all asynchronous operations associated with the descriptor. |
|
|
Close a stream descriptor implementation. |
|
|
Construct a new stream descriptor implementation. |
|
|
Destroy a stream descriptor implementation. |
|
|
Get the io_service object that owns the service. |
|
|
Perform an IO control command on the descriptor. |
|
|
Determine whether the descriptor is open. |
|
|
Move-assign from another stream descriptor implementation. |
|
|
Move-construct a new stream descriptor implementation. |
|
|
(Deprecated: Use native_handle().) Get the native descriptor implementation. |
|
|
Get the native descriptor implementation. |
|
|
Gets the non-blocking mode of the native descriptor implementation. Sets the non-blocking mode of the native descriptor implementation. |
|
|
Gets the non-blocking mode of the descriptor. Sets the non-blocking mode of the descriptor. |
|
|
Read some data from the stream. |
|
|
Release ownership of the native descriptor implementation. |
|
|
Construct a new stream descriptor service for the specified io_service. |
|
|
Write the given data to the stream. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/posix/stream_descriptor_service.hpp
Convenience header: boost/asio.hpp
Assign an existing native descriptor to a stream descriptor.
boost::system::error_code assign( implementation_type & impl, const native_handle_type & native_descriptor, boost::system::error_code & ec);
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_read_some( implementation_type & impl, const MutableBufferSequence & buffers, ReadHandler handler);
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_write_some( implementation_type & impl, const ConstBufferSequence & buffers, WriteHandler handler);
Cancel all asynchronous operations associated with the descriptor.
boost::system::error_code cancel( implementation_type & impl, boost::system::error_code & ec);
Close a stream descriptor implementation.
boost::system::error_code close( implementation_type & impl, boost::system::error_code & ec);
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
The type of a stream descriptor implementation.
typedef implementation_defined implementation_type;
Header: boost/asio/posix/stream_descriptor_service.hpp
Convenience header: boost/asio.hpp
Perform an IO control command on the descriptor.
template< typename IoControlCommand> boost::system::error_code io_control( implementation_type & impl, IoControlCommand & command, boost::system::error_code & ec);
Move-assign from another stream descriptor implementation.
void move_assign( implementation_type & impl, stream_descriptor_service & other_service, implementation_type & other_impl);
Move-construct a new stream descriptor implementation.
void move_construct( implementation_type & impl, implementation_type & other_impl);
(Deprecated: Use native_handle()
.) Get the native descriptor implementation.
native_type native( implementation_type & impl);
Get the native descriptor implementation.
native_handle_type native_handle( implementation_type & impl);
typedef implementation_defined native_handle_type;
Header: boost/asio/posix/stream_descriptor_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the native descriptor implementation.
bool native_non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the native descriptor implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the native descriptor implementation.
bool native_non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the native descriptor implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
(Deprecated: Use native_handle_type.) The native descriptor type.
typedef implementation_defined native_type;
Header: boost/asio/posix/stream_descriptor_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the descriptor.
bool non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the descriptor.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the descriptor.
bool non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the descriptor.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
Read some data from the stream.
template< typename MutableBufferSequence> std::size_t read_some( implementation_type & impl, const MutableBufferSequence & buffers, boost::system::error_code & ec);
Release ownership of the native descriptor implementation.
native_handle_type release( implementation_type & impl);
Construct a new
stream descriptor service for the specified io_service
.
stream_descriptor_service( boost::asio::io_service & io_service);
Write the given data to the stream.
template< typename ConstBufferSequence> std::size_t write_some( implementation_type & impl, const ConstBufferSequence & buffers, boost::system::error_code & ec);
Default service implementation for a raw socket.
template< typename Protocol> class raw_socket_service : public io_service::service
|
Name |
Description |
|---|---|
|
The endpoint type. |
|
|
The type of a raw socket. |
|
|
The native socket type. |
|
|
(Deprecated: Use native_handle_type.) The native socket type. |
|
|
The protocol type. |
|
Name |
Description |
|---|---|
|
Assign an existing native socket to a raw socket. |
|
|
Start an asynchronous connect. |
|
|
Start an asynchronous receive. |
|
|
Start an asynchronous receive that will get the endpoint of the sender. |
|
|
Start an asynchronous send. |
|
|
Start an asynchronous send. |
|
|
Determine whether the socket is at the out-of-band data mark. |
|
|
Determine the number of bytes available for reading. |
|
|
Cancel all asynchronous operations associated with the socket. |
|
|
Close a raw socket implementation. |
|
|
Connect the raw socket to the specified endpoint. |
|
|
Construct a new raw socket implementation. |
|
|
Move-construct a new raw socket implementation from another protocol type. |
|
|
Destroy a raw socket implementation. |
|
|
Get the io_service object that owns the service. |
|
|
Get a socket option. |
|
|
Perform an IO control command on the socket. |
|
|
Determine whether the socket is open. |
|
|
Get the local endpoint. |
|
|
Move-assign from another raw socket implementation. |
|
|
Move-construct a new raw socket implementation. |
|
|
(Deprecated: Use native_handle().) Get the native socket implementation. |
|
|
Get the native socket implementation. |
|
|
Gets the non-blocking mode of the native socket implementation. Sets the non-blocking mode of the native socket implementation. |
|
|
Gets the non-blocking mode of the socket. Sets the non-blocking mode of the socket. |
|
|
Construct a new raw socket service for the specified io_service. |
|
|
Receive some data from the peer. |
|
|
Receive raw data with the endpoint of the sender. |
|
|
Get the remote endpoint. |
|
|
Send the given data to the peer. |
|
|
Send raw data to the specified endpoint. |
|
|
Set a socket option. |
|
|
Disable sends or receives on the socket. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/raw_socket_service.hpp
Convenience header: boost/asio.hpp
Assign an existing native socket to a raw socket.
boost::system::error_code assign( implementation_type & impl, const protocol_type & protocol, const native_handle_type & native_socket, boost::system::error_code & ec);
Start an asynchronous connect.
template< typename ConnectHandler> void-or-deduced async_connect( implementation_type & impl, const endpoint_type & peer_endpoint, ConnectHandler handler);
Start an asynchronous receive.
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_receive( implementation_type & impl, const MutableBufferSequence & buffers, socket_base::message_flags flags, ReadHandler handler);
Start an asynchronous receive that will get the endpoint of the sender.
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_receive_from( implementation_type & impl, const MutableBufferSequence & buffers, endpoint_type & sender_endpoint, socket_base::message_flags flags, ReadHandler handler);
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_send( implementation_type & impl, const ConstBufferSequence & buffers, socket_base::message_flags flags, WriteHandler handler);
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_send_to( implementation_type & impl, const ConstBufferSequence & buffers, const endpoint_type & destination, socket_base::message_flags flags, WriteHandler handler);
Determine whether the socket is at the out-of-band data mark.
bool at_mark( const implementation_type & impl, boost::system::error_code & ec) const;
Determine the number of bytes available for reading.
std::size_t available( const implementation_type & impl, boost::system::error_code & ec) const;
boost::system::error_code bind( implementation_type & impl, const endpoint_type & endpoint, boost::system::error_code & ec);
Cancel all asynchronous operations associated with the socket.
boost::system::error_code cancel( implementation_type & impl, boost::system::error_code & ec);
Close a raw socket implementation.
boost::system::error_code close( implementation_type & impl, boost::system::error_code & ec);
Connect the raw socket to the specified endpoint.
boost::system::error_code connect( implementation_type & impl, const endpoint_type & peer_endpoint, boost::system::error_code & ec);
Move-construct a new raw socket implementation from another protocol type.
template< typename Protocol1> void converting_move_construct( implementation_type & impl, typename raw_socket_service< Protocol1 >::implementation_type & other_impl, typename enable_if< is_convertible< Protocol1, Protocol >::value >::type * = 0);
typedef Protocol::endpoint endpoint_type;
Header: boost/asio/raw_socket_service.hpp
Convenience header: boost/asio.hpp
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
template< typename GettableSocketOption> boost::system::error_code get_option( const implementation_type & impl, GettableSocketOption & option, boost::system::error_code & ec) const;
typedef implementation_defined implementation_type;
Header: boost/asio/raw_socket_service.hpp
Convenience header: boost/asio.hpp
Perform an IO control command on the socket.
template< typename IoControlCommand> boost::system::error_code io_control( implementation_type & impl, IoControlCommand & command, boost::system::error_code & ec);
endpoint_type local_endpoint( const implementation_type & impl, boost::system::error_code & ec) const;
Move-assign from another raw socket implementation.
void move_assign( implementation_type & impl, raw_socket_service & other_service, implementation_type & other_impl);
Move-construct a new raw socket implementation.
void move_construct( implementation_type & impl, implementation_type & other_impl);
(Deprecated: Use native_handle()
.) Get the native socket implementation.
native_type native( implementation_type & impl);
Get the native socket implementation.
native_handle_type native_handle( implementation_type & impl);
typedef implementation_defined native_handle_type;
Header: boost/asio/raw_socket_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the native socket implementation.
bool native_non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the native socket implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the native socket implementation.
bool native_non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the native socket implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
(Deprecated: Use native_handle_type.) The native socket type.
typedef implementation_defined native_type;
Header: boost/asio/raw_socket_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the socket.
bool non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the socket.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the socket.
bool non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the socket.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
boost::system::error_code open( implementation_type & impl, const protocol_type & protocol, boost::system::error_code & ec);
typedef Protocol protocol_type;
Header: boost/asio/raw_socket_service.hpp
Convenience header: boost/asio.hpp
Construct a new raw socket service
for the specified io_service
.
raw_socket_service( boost::asio::io_service & io_service);
Receive some data from the peer.
template< typename MutableBufferSequence> std::size_t receive( implementation_type & impl, const MutableBufferSequence & buffers, socket_base::message_flags flags, boost::system::error_code & ec);
Receive raw data with the endpoint of the sender.
template< typename MutableBufferSequence> std::size_t receive_from( implementation_type & impl, const MutableBufferSequence & buffers, endpoint_type & sender_endpoint, socket_base::message_flags flags, boost::system::error_code & ec);
endpoint_type remote_endpoint( const implementation_type & impl, boost::system::error_code & ec) const;
Send the given data to the peer.
template< typename ConstBufferSequence> std::size_t send( implementation_type & impl, const ConstBufferSequence & buffers, socket_base::message_flags flags, boost::system::error_code & ec);
Send raw data to the specified endpoint.
template< typename ConstBufferSequence> std::size_t send_to( implementation_type & impl, const ConstBufferSequence & buffers, const endpoint_type & destination, socket_base::message_flags flags, boost::system::error_code & ec);
template< typename SettableSocketOption> boost::system::error_code set_option( implementation_type & impl, const SettableSocketOption & option, boost::system::error_code & ec);
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename MutableBufferSequence> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers); » more... template< typename SyncReadStream, typename MutableBufferSequence> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers, boost::system::error_code & ec); » more... template< typename SyncReadStream, typename MutableBufferSequence, typename CompletionCondition> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers, CompletionCondition completion_condition); » more... template< typename SyncReadStream, typename MutableBufferSequence, typename CompletionCondition> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers, CompletionCondition completion_condition, boost::system::error_code & ec); » more... template< typename SyncReadStream, typename Allocator> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b); » more... template< typename SyncReadStream, typename Allocator> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b, boost::system::error_code & ec); » more... template< typename SyncReadStream, typename Allocator, typename CompletionCondition> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b, CompletionCondition completion_condition); » more... template< typename SyncReadStream, typename Allocator, typename CompletionCondition> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b, CompletionCondition completion_condition, boost::system::error_code & ec); » more...
Header: boost/asio/read.hpp
Convenience header: boost/asio.hpp
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename MutableBufferSequence> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the stream.
The number of bytes transferred.
Thrown on failure.
To read into a single data buffer use the buffer
function as follows:
boost::asio::read(s, boost::asio::buffer(data, size));
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
This overload is equivalent to calling:
boost::asio::read( s, buffers, boost::asio::transfer_all());
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename MutableBufferSequence> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the stream.
Set to indicate what error occurred, if any.
The number of bytes transferred.
To read into a single data buffer use the buffer
function as follows:
boost::asio::read(s, boost::asio::buffer(data, size), ec);
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
This overload is equivalent to calling:
boost::asio::read( s, buffers, boost::asio::transfer_all(), ec);
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename MutableBufferSequence, typename CompletionCondition> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers, CompletionCondition completion_condition);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the stream.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the stream's read_some function.
The number of bytes transferred.
Thrown on failure.
To read into a single data buffer use the buffer
function as follows:
boost::asio::read(s, boost::asio::buffer(data, size), boost::asio::transfer_at_least(32));
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename MutableBufferSequence, typename CompletionCondition> std::size_t read( SyncReadStream & s, const MutableBufferSequence & buffers, CompletionCondition completion_condition, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the stream.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the stream's read_some function.
Set to indicate what error occurred, if any.
The number of bytes read. If an error occurs, returns the total number of bytes successfully transferred prior to the error.
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename Allocator> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
The basic_streambuf
object into
which the data will be read.
The number of bytes transferred.
Thrown on failure.
This overload is equivalent to calling:
boost::asio::read( s, b, boost::asio::transfer_all());
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename Allocator> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
The basic_streambuf
object into
which the data will be read.
Set to indicate what error occurred, if any.
The number of bytes transferred.
This overload is equivalent to calling:
boost::asio::read( s, b, boost::asio::transfer_all(), ec);
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename Allocator, typename CompletionCondition> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b, CompletionCondition completion_condition);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
The basic_streambuf
object into
which the data will be read.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the stream's read_some function.
The number of bytes transferred.
Thrown on failure.
Attempt to read a certain amount of data from a stream before returning.
template< typename SyncReadStream, typename Allocator, typename CompletionCondition> std::size_t read( SyncReadStream & s, basic_streambuf< Allocator > & b, CompletionCondition completion_condition, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
The basic_streambuf
object into
which the data will be read.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the stream's read_some function.
Set to indicate what error occurred, if any.
The number of bytes read. If an error occurs, returns the total number of bytes successfully transferred prior to the error.
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers); » more... template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers, boost::system::error_code & ec); » more... template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers, CompletionCondition completion_condition); » more... template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers, CompletionCondition completion_condition, boost::system::error_code & ec); » more... template< typename SyncRandomAccessReadDevice, typename Allocator> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b); » more... template< typename SyncRandomAccessReadDevice, typename Allocator> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b, boost::system::error_code & ec); » more... template< typename SyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b, CompletionCondition completion_condition); » more... template< typename SyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b, CompletionCondition completion_condition, boost::system::error_code & ec); » more...
Header: boost/asio/read_at.hpp
Convenience header: boost/asio.hpp
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the device.
The number of bytes transferred.
Thrown on failure.
To read into a single data buffer use the buffer
function as follows:
boost::asio::read_at(d, 42, boost::asio::buffer(data, size));
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
This overload is equivalent to calling:
boost::asio::read_at( d, 42, buffers, boost::asio::transfer_all());
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the device.
Set to indicate what error occurred, if any.
The number of bytes transferred.
To read into a single data buffer use the buffer
function as follows:
boost::asio::read_at(d, 42, boost::asio::buffer(data, size), ec);
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
This overload is equivalent to calling:
boost::asio::read_at( d, 42, buffers, boost::asio::transfer_all(), ec);
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers, CompletionCondition completion_condition);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the device.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some_at operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the device's read_some_at function.
The number of bytes transferred.
Thrown on failure.
To read into a single data buffer use the buffer
function as follows:
boost::asio::read_at(d, 42, boost::asio::buffer(data, size), boost::asio::transfer_at_least(32));
See the buffer
documentation for information on reading into multiple buffers in one go,
and how to use it with arrays, boost::array or std::vector.
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, const MutableBufferSequence & buffers, CompletionCondition completion_condition, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
One or more buffers into which the data will be read. The sum of the buffer sizes indicates the maximum number of bytes to read from the device.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some_at operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the device's read_some_at function.
Set to indicate what error occurred, if any.
The number of bytes read. If an error occurs, returns the total number of bytes successfully transferred prior to the error.
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename Allocator> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
The basic_streambuf
object into
which the data will be read.
The number of bytes transferred.
Thrown on failure.
This overload is equivalent to calling:
boost::asio::read_at( d, 42, b, boost::asio::transfer_all());
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename Allocator> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
The basic_streambuf
object into
which the data will be read.
Set to indicate what error occurred, if any.
The number of bytes transferred.
This overload is equivalent to calling:
boost::asio::read_at( d, 42, b, boost::asio::transfer_all(), ec);
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b, CompletionCondition completion_condition);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
The basic_streambuf
object into
which the data will be read.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some_at operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the device's read_some_at function.
The number of bytes transferred.
Thrown on failure.
Attempt to read a certain amount of data at the specified offset before returning.
template< typename SyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition> std::size_t read_at( SyncRandomAccessReadDevice & d, uint64_t offset, basic_streambuf< Allocator > & b, CompletionCondition completion_condition, boost::system::error_code & ec);
This function is used to read a certain number of bytes of data from a random access device at the specified offset. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the device's read_some_at function.
The device from which the data is to be read. The type must support the SyncRandomAccessReadDevice concept.
The offset at which the data will be read.
The basic_streambuf
object into
which the data will be read.
The function object to be called to determine whether the read operation is complete. The signature of the function object must be:
std::size_t completion_condition( // Result of latest read_some_at operation. const boost::system::error_code& error, // Number of bytes transferred so far. std::size_t bytes_transferred );
A return value of 0 indicates that the read operation is complete. A non-zero return value indicates the maximum number of bytes to be read on the next call to the device's read_some_at function.
Set to indicate what error occurred, if any.
The number of bytes read. If an error occurs, returns the total number of bytes successfully transferred prior to the error.
Read data into a streambuf until it contains a delimiter, matches a regular expression, or a function object indicates a match.
template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, char delim); » more... template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, char delim, boost::system::error_code & ec); » more... template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const std::string & delim); » more... template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const std::string & delim, boost::system::error_code & ec); » more... template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const boost::regex & expr); » more... template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const boost::regex & expr, boost::system::error_code & ec); » more... template< typename SyncReadStream, typename Allocator, typename MatchCondition> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, MatchCondition match_condition, typename enable_if< is_match_condition< MatchCondition >::value >::type * = 0); » more... template< typename SyncReadStream, typename Allocator, typename MatchCondition> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, MatchCondition match_condition, boost::system::error_code & ec, typename enable_if< is_match_condition< MatchCondition >::value >::type * = 0); » more...
Header: boost/asio/read_until.hpp
Convenience header: boost/asio.hpp
Read data into a streambuf until it contains a specified delimiter.
template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, char delim);
This function is used to read data into the specified streambuf until the streambuf's get area contains the specified delimiter. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the streambuf's get area already contains the delimiter, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The delimiter character.
The number of bytes in the streambuf's get area up to and including the delimiter.
Thrown on failure.
After a successful read_until operation, the streambuf may contain additional data beyond the delimiter. An application will typically leave that data in the streambuf for a subsequent read_until operation to examine.
To read data into a streambuf until a newline is encountered:
boost::asio::streambuf b; boost::asio::read_until(s, b, '\n'); std::istream is(&b); std::string line; std::getline(is, line);
After the read_until
operation
completes successfully, the buffer b
contains the delimiter:
{ 'a', 'b', ..., 'c', '\n', 'd', 'e', ... }
The call to std::getline
then extracts the data up to
and including the delimiter, so that the string line
contains:
{ 'a', 'b', ..., 'c', '\n' }
The remaining data is left in the buffer b
as follows:
{ 'd', 'e', ... }
This data may be the start of a new line, to be extracted by a subsequent
read_until
operation.
Read data into a streambuf until it contains a specified delimiter.
template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, char delim, boost::system::error_code & ec);
This function is used to read data into the specified streambuf until the streambuf's get area contains the specified delimiter. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the streambuf's get area already contains the delimiter, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The delimiter character.
Set to indicate what error occurred, if any.
The number of bytes in the streambuf's get area up to and including the delimiter. Returns 0 if an error occurred.
After a successful read_until operation, the streambuf may contain additional data beyond the delimiter. An application will typically leave that data in the streambuf for a subsequent read_until operation to examine.
Read data into a streambuf until it contains a specified delimiter.
template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const std::string & delim);
This function is used to read data into the specified streambuf until the streambuf's get area contains the specified delimiter. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the streambuf's get area already contains the delimiter, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The delimiter string.
The number of bytes in the streambuf's get area up to and including the delimiter.
Thrown on failure.
After a successful read_until operation, the streambuf may contain additional data beyond the delimiter. An application will typically leave that data in the streambuf for a subsequent read_until operation to examine.
To read data into a streambuf until a newline is encountered:
boost::asio::streambuf b; boost::asio::read_until(s, b, "\r\n"); std::istream is(&b); std::string line; std::getline(is, line);
After the read_until
operation
completes successfully, the buffer b
contains the delimiter:
{ 'a', 'b', ..., 'c', '\r', '\n', 'd', 'e', ... }
The call to std::getline
then extracts the data up to
and including the delimiter, so that the string line
contains:
{ 'a', 'b', ..., 'c', '\r', '\n' }
The remaining data is left in the buffer b
as follows:
{ 'd', 'e', ... }
This data may be the start of a new line, to be extracted by a subsequent
read_until
operation.
Read data into a streambuf until it contains a specified delimiter.
template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const std::string & delim, boost::system::error_code & ec);
This function is used to read data into the specified streambuf until the streambuf's get area contains the specified delimiter. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the streambuf's get area already contains the delimiter, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The delimiter string.
Set to indicate what error occurred, if any.
The number of bytes in the streambuf's get area up to and including the delimiter. Returns 0 if an error occurred.
After a successful read_until operation, the streambuf may contain additional data beyond the delimiter. An application will typically leave that data in the streambuf for a subsequent read_until operation to examine.
Read data into a streambuf until some part of the data it contains matches a regular expression.
template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const boost::regex & expr);
This function is used to read data into the specified streambuf until the streambuf's get area contains some data that matches a regular expression. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the streambuf's get area already contains data that matches the regular expression, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The regular expression.
The number of bytes in the streambuf's get area up to and including the substring that matches the regular expression.
Thrown on failure.
After a successful read_until operation, the streambuf may contain additional data beyond that which matched the regular expression. An application will typically leave that data in the streambuf for a subsequent read_until operation to examine.
To read data into a streambuf until a CR-LF sequence is encountered:
boost::asio::streambuf b; boost::asio::read_until(s, b, boost::regex("\r\n")); std::istream is(&b); std::string line; std::getline(is, line);
After the read_until
operation
completes successfully, the buffer b
contains the data which matched the regular expression:
{ 'a', 'b', ..., 'c', '\r', '\n', 'd', 'e', ... }
The call to std::getline
then extracts the data up to
and including the match, so that the string line
contains:
{ 'a', 'b', ..., 'c', '\r', '\n' }
The remaining data is left in the buffer b
as follows:
{ 'd', 'e', ... }
This data may be the start of a new line, to be extracted by a subsequent
read_until
operation.
Read data into a streambuf until some part of the data it contains matches a regular expression.
template< typename SyncReadStream, typename Allocator> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, const boost::regex & expr, boost::system::error_code & ec);
This function is used to read data into the specified streambuf until the streambuf's get area contains some data that matches a regular expression. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the streambuf's get area already contains data that matches the regular expression, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The regular expression.
Set to indicate what error occurred, if any.
The number of bytes in the streambuf's get area up to and including the substring that matches the regular expression. Returns 0 if an error occurred.
After a successful read_until operation, the streambuf may contain additional data beyond that which matched the regular expression. An application will typically leave that data in the streambuf for a subsequent read_until operation to examine.
Read data into a streambuf until a function object indicates a match.
template< typename SyncReadStream, typename Allocator, typename MatchCondition> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, MatchCondition match_condition, typename enable_if< is_match_condition< MatchCondition >::value >::type * = 0);
This function is used to read data into the specified streambuf until a user-defined match condition function object, when applied to the data contained in the streambuf, indicates a successful match. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the match condition function object already indicates a match, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The function object to be called to determine whether a match exists. The signature of the function object must be:
pair<iterator, bool> match_condition(iterator begin, iterator end);
where iterator
represents
the type:
buffers_iterator<basic_streambuf<Allocator>::const_buffers_type>
The iterator parameters begin
and end
define the
range of bytes to be scanned to determine whether there is a match.
The first
member
of the return value is an iterator marking one-past-the-end of the
bytes that have been consumed by the match function. This iterator
is used to calculate the begin
parameter for any subsequent invocation of the match condition. The
second
member of
the return value is true if a match has been found, false otherwise.
The number of bytes in the streambuf's get area that have been fully consumed by the match function.
Thrown on failure.
After a successful read_until operation, the streambuf may contain additional data beyond that which matched the function object. An application will typically leave that data in the streambuf for a subsequent
The default implementation of the is_match_condition
type trait evaluates to true for function pointers and function objects
with a result_type
typedef.
It must be specialised for other user-defined function objects.
To read data into a streambuf until whitespace is encountered:
typedef boost::asio::buffers_iterator< boost::asio::streambuf::const_buffers_type> iterator; std::pair<iterator, bool> match_whitespace(iterator begin, iterator end) { iterator i = begin; while (i != end) if (std::isspace(*i++)) return std::make_pair(i, true); return std::make_pair(i, false); } ... boost::asio::streambuf b; boost::asio::read_until(s, b, match_whitespace);
To read data into a streambuf until a matching character is found:
class match_char { public: explicit match_char(char c) : c_(c) {} template <typename Iterator> std::pair<Iterator, bool> operator()( Iterator begin, Iterator end) const { Iterator i = begin; while (i != end) if (c_ == *i++) return std::make_pair(i, true); return std::make_pair(i, false); } private: char c_; }; namespace asio { template <> struct is_match_condition<match_char> : public boost::true_type {}; } // namespace asio ... boost::asio::streambuf b; boost::asio::read_until(s, b, match_char('a'));
Read data into a streambuf until a function object indicates a match.
template< typename SyncReadStream, typename Allocator, typename MatchCondition> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, MatchCondition match_condition, boost::system::error_code & ec, typename enable_if< is_match_condition< MatchCondition >::value >::type * = 0);
This function is used to read data into the specified streambuf until a user-defined match condition function object, when applied to the data contained in the streambuf, indicates a successful match. The call will block until one of the following conditions is true:
This operation is implemented in terms of zero or more calls to the stream's read_some function. If the match condition function object already indicates a match, the function returns immediately.
The stream from which the data is to be read. The type must support the SyncReadStream concept.
A streambuf object into which the data will be read.
The function object to be called to determine whether a match exists. The signature of the function object must be:
pair<iterator, bool> match_condition(iterator begin, iterator end);
where iterator
represents
the type:
buffers_iterator<basic_streambuf<Allocator>::const_buffers_type>
The iterator parameters begin
and end
define the
range of bytes to be scanned to determine whether there is a match.
The first
member
of the return value is an iterator marking one-past-the-end of the
bytes that have been consumed by the match function. This iterator
is used to calculate the begin
parameter for any subsequent invocation of the match condition. The
second
member of
the return value is true if a match has been found, false otherwise.
Set to indicate what error occurred, if any.
The number of bytes in the streambuf's get area that have been fully consumed by the match function. Returns 0 if an error occurred.
After a successful read_until operation, the streambuf may contain additional data beyond that which matched the function object. An application will typically leave that data in the streambuf for a subsequent
The default implementation of the is_match_condition
type trait evaluates to true for function pointers and function objects
with a result_type
typedef.
It must be specialised for other user-defined function objects.
Default service implementation for a sequenced packet socket.
template< typename Protocol> class seq_packet_socket_service : public io_service::service
|
Name |
Description |
|---|---|
|
The endpoint type. |
|
|
The type of a sequenced packet socket implementation. |
|
|
The native socket type. |
|
|
(Deprecated: Use native_handle_type.) The native socket type. |
|
|
The protocol type. |
|
Name |
Description |
|---|---|
|
Assign an existing native socket to a sequenced packet socket. |
|
|
Start an asynchronous connect. |
|
|
Start an asynchronous receive. |
|
|
Start an asynchronous send. |
|
|
Determine whether the socket is at the out-of-band data mark. |
|
|
Determine the number of bytes available for reading. |
|
|
Bind the sequenced packet socket to the specified local endpoint. |
|
|
Cancel all asynchronous operations associated with the socket. |
|
|
Close a sequenced packet socket implementation. |
|
|
Connect the sequenced packet socket to the specified endpoint. |
|
|
Construct a new sequenced packet socket implementation. |
|
|
Move-construct a new sequenced packet socket implementation from another protocol type. |
|
|
Destroy a sequenced packet socket implementation. |
|
|
Get the io_service object that owns the service. |
|
|
Get a socket option. |
|
|
Perform an IO control command on the socket. |
|
|
Determine whether the socket is open. |
|
|
Get the local endpoint. |
|
|
Move-assign from another sequenced packet socket implementation. |
|
|
Move-construct a new sequenced packet socket implementation. |
|
|
(Deprecated: Use native_handle().) Get the native socket implementation. |
|
|
Get the native socket implementation. |
|
|
Gets the non-blocking mode of the native socket implementation. Sets the non-blocking mode of the native socket implementation. |
|
|
Gets the non-blocking mode of the socket. Sets the non-blocking mode of the socket. |
|
|
Open a sequenced packet socket. |
|
|
Receive some data from the peer. |
|
|
Get the remote endpoint. |
|
|
Send the given data to the peer. |
|
|
Construct a new sequenced packet socket service for the specified io_service. |
|
|
Set a socket option. |
|
|
Disable sends or receives on the socket. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/seq_packet_socket_service.hpp
Convenience header: boost/asio.hpp
Assign an existing native socket to a sequenced packet socket.
boost::system::error_code assign( implementation_type & impl, const protocol_type & protocol, const native_handle_type & native_socket, boost::system::error_code & ec);
Start an asynchronous connect.
template< typename ConnectHandler> void-or-deduced async_connect( implementation_type & impl, const endpoint_type & peer_endpoint, ConnectHandler handler);
Start an asynchronous receive.
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_receive( implementation_type & impl, const MutableBufferSequence & buffers, socket_base::message_flags in_flags, socket_base::message_flags & out_flags, ReadHandler handler);
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_send( implementation_type & impl, const ConstBufferSequence & buffers, socket_base::message_flags flags, WriteHandler handler);
Determine whether the socket is at the out-of-band data mark.
bool at_mark( const implementation_type & impl, boost::system::error_code & ec) const;
Determine the number of bytes available for reading.
std::size_t available( const implementation_type & impl, boost::system::error_code & ec) const;
Bind the sequenced packet socket to the specified local endpoint.
boost::system::error_code bind( implementation_type & impl, const endpoint_type & endpoint, boost::system::error_code & ec);
Cancel all asynchronous operations associated with the socket.
boost::system::error_code cancel( implementation_type & impl, boost::system::error_code & ec);
Close a sequenced packet socket implementation.
boost::system::error_code close( implementation_type & impl, boost::system::error_code & ec);
Connect the sequenced packet socket to the specified endpoint.
boost::system::error_code connect( implementation_type & impl, const endpoint_type & peer_endpoint, boost::system::error_code & ec);
Construct a new sequenced packet socket implementation.
void construct( implementation_type & impl);
Move-construct a new sequenced packet socket implementation from another protocol type.
template< typename Protocol1> void converting_move_construct( implementation_type & impl, typename seq_packet_socket_service< Protocol1 >::implementation_type & other_impl, typename enable_if< is_convertible< Protocol1, Protocol >::value >::type * = 0);
typedef Protocol::endpoint endpoint_type;
Header: boost/asio/seq_packet_socket_service.hpp
Convenience header: boost/asio.hpp
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
template< typename GettableSocketOption> boost::system::error_code get_option( const implementation_type & impl, GettableSocketOption & option, boost::system::error_code & ec) const;
The type of a sequenced packet socket implementation.
typedef implementation_defined implementation_type;
Header: boost/asio/seq_packet_socket_service.hpp
Convenience header: boost/asio.hpp
Perform an IO control command on the socket.
template< typename IoControlCommand> boost::system::error_code io_control( implementation_type & impl, IoControlCommand & command, boost::system::error_code & ec);
endpoint_type local_endpoint( const implementation_type & impl, boost::system::error_code & ec) const;
Move-assign from another sequenced packet socket implementation.
void move_assign( implementation_type & impl, seq_packet_socket_service & other_service, implementation_type & other_impl);
Move-construct a new sequenced packet socket implementation.
void move_construct( implementation_type & impl, implementation_type & other_impl);
(Deprecated: Use native_handle()
.) Get the native socket implementation.
native_type native( implementation_type & impl);
Get the native socket implementation.
native_handle_type native_handle( implementation_type & impl);
typedef implementation_defined native_handle_type;
Header: boost/asio/seq_packet_socket_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the native socket implementation.
bool native_non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the native socket implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the native socket implementation.
bool native_non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the native socket implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
(Deprecated: Use native_handle_type.) The native socket type.
typedef implementation_defined native_type;
Header: boost/asio/seq_packet_socket_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the socket.
bool non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the socket.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the socket.
bool non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the socket.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
Open a sequenced packet socket.
boost::system::error_code open( implementation_type & impl, const protocol_type & protocol, boost::system::error_code & ec);
typedef Protocol protocol_type;
Header: boost/asio/seq_packet_socket_service.hpp
Convenience header: boost/asio.hpp
Receive some data from the peer.
template< typename MutableBufferSequence> std::size_t receive( implementation_type & impl, const MutableBufferSequence & buffers, socket_base::message_flags in_flags, socket_base::message_flags & out_flags, boost::system::error_code & ec);
endpoint_type remote_endpoint( const implementation_type & impl, boost::system::error_code & ec) const;
Send the given data to the peer.
template< typename ConstBufferSequence> std::size_t send( implementation_type & impl, const ConstBufferSequence & buffers, socket_base::message_flags flags, boost::system::error_code & ec);
Construct a new sequenced
packet socket service for the specified io_service
.
seq_packet_socket_service( boost::asio::io_service & io_service);
template< typename SettableSocketOption> boost::system::error_code set_option( implementation_type & impl, const SettableSocketOption & option, boost::system::error_code & ec);
Typedef for the typical usage of a serial port.
typedef basic_serial_port serial_port;
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
A basic_serial_port is always the lowest layer. |
|
|
The native representation of a serial port. |
|
|
(Deprecated: Use native_handle_type.) The native representation of a serial port. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Assign an existing native serial port to the serial port. |
|
|
Start an asynchronous read. |
|
|
Start an asynchronous write. |
|
|
Construct a basic_serial_port without opening it. Construct and open a basic_serial_port. Construct a basic_serial_port on an existing native serial port.  Get a const reference to the lowest layer. |
|
|
(Deprecated: Use native_handle().) Get the native serial port representation. |
|
|
Get the native serial port representation. |
|
|
Open the serial port using the specified device name. |
|
|
Move-assign a basic_serial_port from another. |
|
|
Read some data from the serial port. |
|
|
Send a break sequence to the serial port. |
|
|
Set an option on the serial port. |
|
|
Write some data to the serial port. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The basic_serial_port
class template
provides functionality that is common to all serial ports.
Distinct objects: Safe.
Shared objects: Unsafe.
Header: boost/asio/serial_port.hpp
Convenience header: boost/asio.hpp
The serial_port_base
class is used as a base for the basic_serial_port
class template
so that we have a common place to define the serial port options.
class serial_port_base
|
Name |
Description |
|---|---|
|
Serial port option to permit changing the baud rate. |
|
|
Serial port option to permit changing the character size. |
|
|
Serial port option to permit changing the flow control. |
|
|
Serial port option to permit changing the parity. |
|
|
Serial port option to permit changing the number of stop bits. |
|
Name |
Description |
|---|---|
|
Protected destructor to prevent deletion through this type. |
Header: boost/asio/serial_port_base.hpp
Convenience header: boost/asio.hpp
Serial port option to permit changing the baud rate.
class baud_rate
Implements changing the baud rate for a given serial port.
Header: boost/asio/serial_port_base.hpp
Convenience header: boost/asio.hpp
boost::system::error_code load( const BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec);
boost::system::error_code store( BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec) const;
Serial port option to permit changing the character size.
class character_size
|
Name |
Description |
|---|---|
Implements changing the character size for a given serial port.
Header: boost/asio/serial_port_base.hpp
Convenience header: boost/asio.hpp
boost::system::error_code load( const BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec);
boost::system::error_code store( BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec) const;
Serial port option to permit changing the flow control.
class flow_control
|
Name |
Description |
|---|---|
|
Name |
Description |
|---|---|
Implements changing the flow control for a given serial port.
Header: boost/asio/serial_port_base.hpp
Convenience header: boost/asio.hpp
boost::system::error_code load( const BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec);
boost::system::error_code store( BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec) const;
Serial port option to permit changing the parity.
class parity
|
Name |
Description |
|---|---|
Implements changing the parity for a given serial port.
Header: boost/asio/serial_port_base.hpp
Convenience header: boost/asio.hpp
boost::system::error_code load( const BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec);
boost::system::error_code store( BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec) const;
Serial port option to permit changing the number of stop bits.
class stop_bits
|
Name |
Description |
|---|---|
Implements changing the number of stop bits for a given serial port.
Header: boost/asio/serial_port_base.hpp
Convenience header: boost/asio.hpp
boost::system::error_code load( const BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec);
boost::system::error_code store( BOOST_ASIO_OPTION_STORAGE & storage, boost::system::error_code & ec) const;
Default service implementation for a serial port.
class serial_port_service : public io_service::service
|
Name |
Description |
|---|---|
|
The type of a serial port implementation. |
|
|
The native handle type. |
|
|
(Deprecated: Use native_handle_type.)  Get the native handle implementation. |
|
|
Get the native handle implementation. |
|
|
Open a serial port. |
|
|
Read some data from the stream. |
|
|
Send a break sequence to the serial port. |
|
|
Construct a new serial port service for the specified io_service. |
|
|
Set a serial port option. |
|
|
Write the given data to the stream. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/serial_port_service.hpp
Convenience header: boost/asio.hpp
Assign an existing native handle to a serial port.
boost::system::error_code assign( implementation_type & impl, const native_handle_type & handle, boost::system::error_code & ec);
template< typename MutableBufferSequence, typename ReadHandler> void-or-deduced async_read_some( implementation_type & impl, const MutableBufferSequence & buffers, ReadHandler handler);
template< typename ConstBufferSequence, typename WriteHandler> void-or-deduced async_write_some( implementation_type & impl, const ConstBufferSequence & buffers, WriteHandler handler);
Cancel all asynchronous operations associated with the handle.
boost::system::error_code cancel( implementation_type & impl, boost::system::error_code & ec);
Close a serial port implementation.
boost::system::error_code close( implementation_type & impl, boost::system::error_code & ec);
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
template< typename GettableSerialPortOption> boost::system::error_code get_option( const implementation_type & impl, GettableSerialPortOption & option, boost::system::error_code & ec) const;
The type of a serial port implementation.
typedef implementation_defined implementation_type;
Header: boost/asio/serial_port_service.hpp
Convenience header: boost/asio.hpp
Move-assign from another serial port implementation.
void move_assign( implementation_type & impl, serial_port_service & other_service, implementation_type & other_impl);
Move-construct a new serial port implementation.
void move_construct( implementation_type & impl, implementation_type & other_impl);
(Deprecated: Use native_handle()
.)  The native handle type.
typedef implementation_defined native_type;
Header: boost/asio/serial_port_service.hpp
Convenience header: boost/asio.hpp
boost::system::error_code open( implementation_type & impl, const std::string & device, boost::system::error_code & ec);
Read some data from the stream.
template< typename MutableBufferSequence> std::size_t read_some( implementation_type & impl, const MutableBufferSequence & buffers, boost::system::error_code & ec);
Send a break sequence to the serial port.
boost::system::error_code send_break( implementation_type & impl, boost::system::error_code & ec);
Construct a new serial port service
for the specified io_service
.
serial_port_service( boost::asio::io_service & io_service);
template< typename SettableSerialPortOption> boost::system::error_code set_option( implementation_type & impl, const SettableSerialPortOption & option, boost::system::error_code & ec);
Write the given data to the stream.
template< typename ConstBufferSequence> std::size_t write_some( implementation_type & impl, const ConstBufferSequence & buffers, boost::system::error_code & ec);
Exception thrown when trying to add a duplicate service to an io_service
.
class service_already_exists
|
Name |
Description |
|---|---|
Header: boost/asio/io_service.hpp
Convenience header: boost/asio.hpp
Typedef for the typical usage of a signal set.
typedef basic_signal_set signal_set;
|
Name |
Description |
|---|---|
|
The underlying implementation type of I/O object. |
|
|
The type of the service that will be used to provide I/O operations. |
|
Name |
Description |
|---|---|
|
Add a signal to a signal_set. |
|
|
Start an asynchronous operation to wait for a signal to be delivered. |
|
|
Construct a signal set without adding any signals. Construct a signal set and add one signal. Construct a signal set and add two signals. Construct a signal set and add three signals. |
|
|
Cancel all operations associated with the signal set. |
|
|
Remove all signals from a signal_set. |
|
|
Get the io_service associated with the object. |
|
|
Remove a signal from a signal_set. |
|
Name |
Description |
|---|---|
|
Get the underlying implementation of the I/O object. |
|
|
Get the service associated with the I/O object. |
|
Name |
Description |
|---|---|
|
(Deprecated: Use get_implementation().) The underlying implementation of the I/O object. |
|
|
(Deprecated: Use get_service().) The service associated with the I/O object. |
The basic_signal_set
class template provides the ability to perform an asynchronous wait for one
or more signals to occur.
Most applications will use the signal_set
typedef.
Distinct objects: Safe.
Shared objects: Unsafe.
Performing an asynchronous wait:
void handler( const boost::system::error_code& error, int signal_number) { if (!error) { // A signal occurred. } } ... // Construct a signal set registered for process termination. boost::asio::signal_set signals(io_service, SIGINT, SIGTERM); // Start an asynchronous wait for one of the signals to occur. signals.async_wait(handler);
If a signal is registered with a signal_set, and the signal occurs when there are no waiting handlers, then the signal notification is queued. The next async_wait operation on that signal_set will dequeue the notification. If multiple notifications are queued, subsequent async_wait operations dequeue them one at a time. Signal notifications are dequeued in order of ascending signal number.
If a signal number is removed from a signal_set (using the remove
or erase
member functions) then any queued notifications for that signal are discarded.
The same signal number may be registered with different signal_set objects. When the signal occurs, one handler is called for each signal_set object.
Note that multiple registration only works for signals that are registered
using Asio. The application must not also register a signal handler using
functions such as signal()
or sigaction()
.
POSIX allows signals to be blocked using functions such as sigprocmask()
and pthread_sigmask()
.
For signals to be delivered, programs must ensure that any signals registered
using signal_set objects are unblocked in at least one thread.
Header: boost/asio/signal_set.hpp
Convenience header: boost/asio.hpp
Default service implementation for a signal set.
class signal_set_service : public io_service::service
|
Name |
Description |
|---|---|
|
The type of a signal set implementation. |
|
Name |
Description |
|---|---|
|
Add a signal to a signal_set. |
|
|
Cancel all operations associated with the signal set. |
|
|
Remove all signals from a signal_set. |
|
|
Construct a new signal set implementation. |
|
|
Destroy a signal set implementation. |
|
|
Get the io_service object that owns the service. |
|
|
Remove a signal to a signal_set. |
|
|
Construct a new signal set service for the specified io_service. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/signal_set_service.hpp
Convenience header: boost/asio.hpp
boost::system::error_code add( implementation_type & impl, int signal_number, boost::system::error_code & ec);
template< typename SignalHandler> void-or-deduced async_wait( implementation_type & impl, SignalHandler handler);
Cancel all operations associated with the signal set.
boost::system::error_code cancel( implementation_type & impl, boost::system::error_code & ec);
Remove all signals from a signal_set.
boost::system::error_code clear( implementation_type & impl, boost::system::error_code & ec);
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
The type of a signal set implementation.
typedef implementation_defined implementation_type;
Header: boost/asio/signal_set_service.hpp
Convenience header: boost/asio.hpp
Remove a signal to a signal_set.
boost::system::error_code remove( implementation_type & impl, int signal_number, boost::system::error_code & ec);
Construct a new signal set service
for the specified io_service
.
signal_set_service( boost::asio::io_service & io_service);
Default service implementation for a socket acceptor.
template< typename Protocol> class socket_acceptor_service : public io_service::service
|
Name |
Description |
|---|---|
|
The endpoint type. |
|
|
The native type of the socket acceptor. |
|
|
The native acceptor type. |
|
|
(Deprecated: Use native_handle_type.) The native acceptor type. |
|
|
The protocol type. |
|
Name |
Description |
|---|---|
|
Accept a new connection. |
|
|
Assign an existing native acceptor to a socket acceptor. |
|
|
Start an asynchronous accept. |
|
|
Bind the socket acceptor to the specified local endpoint. |
|
|
Cancel all asynchronous operations associated with the acceptor. |
|
|
Close a socket acceptor implementation. |
|
|
Construct a new socket acceptor implementation. |
|
|
Move-construct a new socket acceptor implementation from another protocol type. |
|
|
Destroy a socket acceptor implementation. |
|
|
Get the io_service object that owns the service. |
|
|
Get a socket option. |
|
|
Perform an IO control command on the socket. |
|
|
Determine whether the acceptor is open. |
|
|
Place the socket acceptor into the state where it will listen for new connections. |
|
|
Get the local endpoint. |
|
|
Move-assign from another socket acceptor implementation. |
|
|
Move-construct a new socket acceptor implementation. |
|
|
(Deprecated: Use native_handle().) Get the native acceptor implementation. |
|
|
Get the native acceptor implementation. |
|
|
Gets the non-blocking mode of the native acceptor implementation. Sets the non-blocking mode of the native acceptor implementation. |
|
|
Gets the non-blocking mode of the acceptor. Sets the non-blocking mode of the acceptor. |
|
|
Open a new socket acceptor implementation. |
|
|
Set a socket option. |
|
|
Construct a new socket acceptor service for the specified io_service. |
|
Name |
Description |
|---|---|
|
The unique service identifier. |
Header: boost/asio/socket_acceptor_service.hpp
Convenience header: boost/asio.hpp
template< typename Protocol1, typename SocketService> boost::system::error_code accept( implementation_type & impl, basic_socket< Protocol1, SocketService > & peer, endpoint_type * peer_endpoint, boost::system::error_code & ec, typename enable_if< is_convertible< Protocol, Protocol1 >::value >::type * = 0);
Assign an existing native acceptor to a socket acceptor.
boost::system::error_code assign( implementation_type & impl, const protocol_type & protocol, const native_handle_type & native_acceptor, boost::system::error_code & ec);
template< typename Protocol1, typename SocketService, typename AcceptHandler> void-or-deduced async_accept( implementation_type & impl, basic_socket< Protocol1, SocketService > & peer, endpoint_type * peer_endpoint, AcceptHandler handler, typename enable_if< is_convertible< Protocol, Protocol1 >::value >::type * = 0);
Bind the socket acceptor to the specified local endpoint.
boost::system::error_code bind( implementation_type & impl, const endpoint_type & endpoint, boost::system::error_code & ec);
Cancel all asynchronous operations associated with the acceptor.
boost::system::error_code cancel( implementation_type & impl, boost::system::error_code & ec);
Close a socket acceptor implementation.
boost::system::error_code close( implementation_type & impl, boost::system::error_code & ec);
Move-construct a new socket acceptor implementation from another protocol type.
template< typename Protocol1> void converting_move_construct( implementation_type & impl, typename socket_acceptor_service< Protocol1 >::implementation_type & other_impl, typename enable_if< is_convertible< Protocol1, Protocol >::value >::type * = 0);
typedef protocol_type::endpoint endpoint_type;
Header: boost/asio/socket_acceptor_service.hpp
Convenience header: boost/asio.hpp
Inherited from io_service.
Get the io_service
object that owns the
service.
boost::asio::io_service & get_io_service();
template< typename GettableSocketOption> boost::system::error_code get_option( const implementation_type & impl, GettableSocketOption & option, boost::system::error_code & ec) const;
The native type of the socket acceptor.
typedef implementation_defined implementation_type;
Header: boost/asio/socket_acceptor_service.hpp
Convenience header: boost/asio.hpp
Perform an IO control command on the socket.
template< typename IoControlCommand> boost::system::error_code io_control( implementation_type & impl, IoControlCommand & command, boost::system::error_code & ec);
Place the socket acceptor into the state where it will listen for new connections.
boost::system::error_code listen( implementation_type & impl, int backlog, boost::system::error_code & ec);
endpoint_type local_endpoint( const implementation_type & impl, boost::system::error_code & ec) const;
Move-assign from another socket acceptor implementation.
void move_assign( implementation_type & impl, socket_acceptor_service & other_service, implementation_type & other_impl);
Move-construct a new socket acceptor implementation.
void move_construct( implementation_type & impl, implementation_type & other_impl);
(Deprecated: Use native_handle()
.) Get the native acceptor implementation.
native_type native( implementation_type & impl);
Get the native acceptor implementation.
native_handle_type native_handle( implementation_type & impl);
typedef implementation_defined native_handle_type;
Header: boost/asio/socket_acceptor_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the native acceptor implementation.
bool native_non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the native acceptor implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the native acceptor implementation.
bool native_non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the native acceptor implementation.
boost::system::error_code native_non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
(Deprecated: Use native_handle_type.) The native acceptor type.
typedef implementation_defined native_type;
Header: boost/asio/socket_acceptor_service.hpp
Convenience header: boost/asio.hpp
Gets the non-blocking mode of the acceptor.
bool non_blocking( const implementation_type & impl) const; » more...
Sets the non-blocking mode of the acceptor.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec); » more...
Gets the non-blocking mode of the acceptor.
bool non_blocking( const implementation_type & impl) const;
Sets the non-blocking mode of the acceptor.
boost::system::error_code non_blocking( implementation_type & impl, bool mode, boost::system::error_code & ec);
Open a new socket acceptor implementation.
boost::system::error_code open( implementation_type & impl, const protocol_type & protocol, boost::system::error_code & ec);
typedef Protocol protocol_type;
Header: boost/asio/socket_acceptor_service.hpp
Convenience header: boost/asio.hpp
template< typename SettableSocketOption> boost::system::error_code set_option( implementation_type & impl, const SettableSocketOption & option, boost::system::error_code & ec);
Construct a new socket acceptor
service for the specified io_service
.
socket_acceptor_service( boost::asio::io_service & io_service);
The socket_base
class is used as a base for the basic_stream_socket
and basic_datagram_socket
class templates
so that we have a common place to define the shutdown_type and enum.
class socket_base
|
Name |
Description |
|---|---|
|
Socket option to permit sending of broadcast messages. |
|
|
IO control command to get the amount of data that can be read without blocking. |
|
|
Socket option to enable socket-level debugging. |
|
|
Socket option to prevent routing, use local interfaces only. |
|
|
Socket option to report aborted connections on accept. |
|
|
Socket option to send keep-alives. |
|
|
Socket option to specify whether the socket lingers on close if unsent data is present. |
|
|
Bitmask type for flags that can be passed to send and receive operations. |
|
|
(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. |
|
|
Socket option for the receive buffer size of a socket. |
|
|
Socket option for the receive low watermark. |
|
|
Socket option to allow the socket to be bound to an address that is already in use. |
|
|
Socket option for the send buffer size of a socket. |
|
|
Socket option for the send low watermark. |
|
|
Different ways a socket may be shutdown. |
|
Name |
Description |
|---|---|
|
Protected destructor to prevent deletion through this type. |
|
Name |
Description |
|---|---|
|
The maximum length of the queue of pending incoming connections. |
|
|
Specify that the data should not be subject to routing. |
|
|
Specifies that the data marks the end of a record. |
|
|
Process out-of-band data. |
|
|
Peek at incoming data without removing it from the input queue. |
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option to permit sending of broadcast messages.
typedef implementation_defined broadcast;
Implements the SOL_SOCKET/SO_BROADCAST socket option.
Setting the option:
boost::asio::ip::udp::socket socket(io_service); ... boost::asio::socket_base::broadcast option(true); socket.set_option(option);
Getting the current option value:
boost::asio::ip::udp::socket socket(io_service); ... boost::asio::socket_base::broadcast option; socket.get_option(option); bool is_set = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
IO control command to get the amount of data that can be read without blocking.
typedef implementation_defined bytes_readable;
Implements the FIONREAD IO control command.
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::bytes_readable command(true); socket.io_control(command); std::size_t bytes_readable = command.get();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option to enable socket-level debugging.
typedef implementation_defined debug;
Implements the SOL_SOCKET/SO_DEBUG socket option.
Setting the option:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::debug option(true); socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::debug option; socket.get_option(option); bool is_set = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option to prevent routing, use local interfaces only.
typedef implementation_defined do_not_route;
Implements the SOL_SOCKET/SO_DONTROUTE socket option.
Setting the option:
boost::asio::ip::udp::socket socket(io_service); ... boost::asio::socket_base::do_not_route option(true); socket.set_option(option);
Getting the current option value:
boost::asio::ip::udp::socket socket(io_service); ... boost::asio::socket_base::do_not_route option; socket.get_option(option); bool is_set = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option to report aborted connections on accept.
typedef implementation_defined enable_connection_aborted;
Implements a custom socket option that determines whether or not an accept
operation is permitted to fail with boost::asio::error::connection_aborted
.
By default the option is false.
Setting the option:
boost::asio::ip::tcp::acceptor acceptor(io_service); ... boost::asio::socket_base::enable_connection_aborted option(true); acceptor.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::acceptor acceptor(io_service); ... boost::asio::socket_base::enable_connection_aborted option; acceptor.get_option(option); bool is_set = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option to send keep-alives.
typedef implementation_defined keep_alive;
Implements the SOL_SOCKET/SO_KEEPALIVE socket option.
Setting the option:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::keep_alive option(true); socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::keep_alive option; socket.get_option(option); bool is_set = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option to specify whether the socket lingers on close if unsent data is present.
typedef implementation_defined linger;
Implements the SOL_SOCKET/SO_LINGER socket option.
Setting the option:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::linger option(true, 30); socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::linger option; socket.get_option(option); bool is_set = option.enabled(); unsigned short timeout = option.timeout();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
The maximum length of the queue of pending incoming connections.
static const int max_connections = implementation_defined;
Specify that the data should not be subject to routing.
static const int message_do_not_route = implementation_defined;
Specifies that the data marks the end of a record.
static const int message_end_of_record = implementation_defined;
Bitmask type for flags that can be passed to send and receive operations.
typedef int message_flags;
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
static const int message_out_of_band = implementation_defined;
Peek at incoming data without removing it from the input queue.
static const int message_peek = implementation_defined;
(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket.
typedef implementation_defined non_blocking_io;
Implements the FIONBIO IO control command.
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::non_blocking_io command(true); socket.io_control(command);
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option for the receive buffer size of a socket.
typedef implementation_defined receive_buffer_size;
Implements the SOL_SOCKET/SO_RCVBUF socket option.
Setting the option:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::receive_buffer_size option(8192); socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::receive_buffer_size option; socket.get_option(option); int size = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option for the receive low watermark.
typedef implementation_defined receive_low_watermark;
Implements the SOL_SOCKET/SO_RCVLOWAT socket option.
Setting the option:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::receive_low_watermark option(1024); socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::receive_low_watermark option; socket.get_option(option); int size = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option to allow the socket to be bound to an address that is already in use.
typedef implementation_defined reuse_address;
Implements the SOL_SOCKET/SO_REUSEADDR socket option.
Setting the option:
boost::asio::ip::tcp::acceptor acceptor(io_service); ... boost::asio::socket_base::reuse_address option(true); acceptor.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::acceptor acceptor(io_service); ... boost::asio::socket_base::reuse_address option; acceptor.get_option(option); bool is_set = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option for the send buffer size of a socket.
typedef implementation_defined send_buffer_size;
Implements the SOL_SOCKET/SO_SNDBUF socket option.
Setting the option:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::send_buffer_size option(8192); socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::send_buffer_size option; socket.get_option(option); int size = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Socket option for the send low watermark.
typedef implementation_defined send_low_watermark;
Implements the SOL_SOCKET/SO_SNDLOWAT socket option.
Setting the option:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::send_low_watermark option(1024); socket.set_option(option);
Getting the current option value:
boost::asio::ip::tcp::socket socket(io_service); ... boost::asio::socket_base::send_low_watermark option; socket.get_option(option); int size = option.value();
Header: boost/asio/socket_base.hpp
Convenience header: boost/asio.hpp
Different ways a socket may be shutdown.
enum shutdown_type
Shutdown the receive side of the socket.
Shutdown the send side of the socket.
Shutdown both send and receive on the socket.
Start a new stackful coroutine.
template< typename Handler, typename Function> void spawn( Handler handler, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes()); » more... template< typename Handler, typename Function> void spawn( basic_yield_context< Handler > ctx, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes()); » more... template< typename Function> void spawn( boost::asio::io_service::strand strand, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes()); » more... template< typename Function> void spawn( boost::asio::io_service & io_service, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes()); » more...
The spawn()
function is a high-level wrapper over the Boost.Coroutine library. This function
enables programs to implement asynchronous logic in a synchronous manner,
as illustrated by the following example:
boost::asio::spawn(my_strand, do_echo); // ... void do_echo(boost::asio::yield_context yield) { try { char data[128]; for (;;) { std::size_t length = my_socket.async_read_some( boost::asio::buffer(data), yield); boost::asio::async_write(my_socket, boost::asio::buffer(data, length), yield); } } catch (std::exception& e) { // ... } }
Header: boost/asio/spawn.hpp
Convenience header: None
Start a new stackful coroutine, calling the specified handler when it completes.
template< typename Handler, typename Function> void spawn( Handler handler, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
This function is used to launch a new coroutine.
A handler to be called when the coroutine exits. More importantly, the handler provides an execution context (via the the handler invocation hook) for the coroutine. The handler must have the signature:
void handler();
The coroutine function. The function must have the signature:
void function(basic_yield_context<Handler> yield);
Boost.Coroutine attributes used to customise the coroutine.
Start a new stackful coroutine, inheriting the execution context of another.
template< typename Handler, typename Function> void spawn( basic_yield_context< Handler > ctx, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
This function is used to launch a new coroutine.
Identifies the current coroutine as a parent of the new coroutine. This specifies that the new coroutine should inherit the execution context of the parent. For example, if the parent coroutine is executing in a particular strand, then the new coroutine will execute in the same strand.
The coroutine function. The function must have the signature:
void function(basic_yield_context<Handler> yield);
Boost.Coroutine attributes used to customise the coroutine.
Start a new stackful coroutine that executes in the context of a strand.
template< typename Function> void spawn( boost::asio::io_service::strand strand, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
This function is used to launch a new coroutine.
Identifies a strand. By starting multiple coroutines on the same strand, the implementation ensures that none of those coroutines can execute simultaneously.
The coroutine function. The function must have the signature:
void function(yield_context yield);
Boost.Coroutine attributes used to customise the coroutine.
Start a new stackful coroutine that executes on a given io_service
.
template< typename Function> void spawn( boost::asio::io_service & io_service, Function function, const boost::coroutines::attributes & attributes = boost::coroutines::attributes());
This function is used to launch a new coroutine.
Identifies the io_service
that will run
the coroutine. The new coroutine is implicitly given its own strand
within this io_service
.
The coroutine function. The function must have the signature:
void function(yield_context yield);
Boost.Coroutine attributes used to customise the coroutine.
class context : public ssl::context_base, noncopyable
|
Name |
Description |
|---|---|
|
File format types. |
|
|
(Deprecated: Use native_handle_type.) The native type of the SSL context. |
|
|
Different methods supported by a context. |
|
|
The native handle type of the SSL context. |
|
|
Bitmask type for SSL options. |
|
|
Purpose of PEM password. |
|
Name |
Description |
|---|---|
|
Add certification authority for performing verification. |
|
|
Add a directory containing certificate authority files to be used for performing verification. |
|
|
Clear options on the context. |
|
|
Constructor. Deprecated constructor taking a reference to an io_service object. Move-construct a context from another. |
|
|
(Deprecated: Use native_handle().) Get the underlying implementation in the native type. |
|
|
Load a certification authority file for performing verification. |
|
|
Get the underlying implementation in the native type. |
|
|
Move-assign a context from another. |
|
|
Configures the context to use the default directories for finding certification authority certificates. |
|
|
Set options on the context. |
|
|
Set the password callback. |
|
|
Set the callback used to verify peer certificates. |
|
|
Set the peer verification depth. |
|
|
Set the peer verification mode. |
|
|
Use a certificate from a memory buffer. |
|
|
Use a certificate chain from a memory buffer. |
|
|
Use a certificate chain from a file. |
|
|
Use a certificate from a file. |
|
|
Use a private key from a memory buffer. |
|
|
Use a private key from a file. |
|
|
Use an RSA private key from a memory buffer. |
|
|
Use an RSA private key from a file. |
|
|
Use the specified memory buffer to obtain the temporary Diffie-Hellman parameters. |
|
|
Use the specified file to obtain the temporary Diffie-Hellman parameters. |
|
|
Destructor. |
|
Name |
Description |
|---|---|
|
Implement various bug workarounds. |
|
|
Disable compression. Compression is disabled by default. |
|
|
Disable SSL v2. |
|
|
Disable SSL v3. |
|
|
Disable TLS v1. |
|
|
Disable TLS v1.1. |
|
|
Disable TLS v1.2. |
|
|
Always create a new key when using tmp_dh parameters. |
Header: boost/asio/ssl/context.hpp
Convenience header: boost/asio/ssl.hpp
Add certification authority for performing verification.
void add_certificate_authority( const const_buffer & ca); » more... boost::system::error_code add_certificate_authority( const const_buffer & ca, boost::system::error_code & ec); » more...
Add certification authority for performing verification.
void add_certificate_authority( const const_buffer & ca);
This function is used to add one trusted certification authority from a memory buffer.
The buffer containing the certification authority certificate. The certificate must use the PEM format.
Thrown on failure.
Calls SSL_CTX_get_cert_store
and X509_STORE_add_cert
.
Add certification authority for performing verification.
boost::system::error_code add_certificate_authority( const const_buffer & ca, boost::system::error_code & ec);
This function is used to add one trusted certification authority from a memory buffer.
The buffer containing the certification authority certificate. The certificate must use the PEM format.
Set to indicate what error occurred, if any.
Calls SSL_CTX_get_cert_store
and X509_STORE_add_cert
.
Add a directory containing certificate authority files to be used for performing verification.
void add_verify_path( const std::string & path); » more... boost::system::error_code add_verify_path( const std::string & path, boost::system::error_code & ec); » more...
Add a directory containing certificate authority files to be used for performing verification.
void add_verify_path( const std::string & path);
This function is used to specify the name of a directory containing certification authority certificates. Each file in the directory must contain a single certificate. The files must be named using the subject name's hash and an extension of ".0".
The name of a directory containing the certificates.
Thrown on failure.
Calls SSL_CTX_load_verify_locations
.
Add a directory containing certificate authority files to be used for performing verification.
boost::system::error_code add_verify_path( const std::string & path, boost::system::error_code & ec);
This function is used to specify the name of a directory containing certification authority certificates. Each file in the directory must contain a single certificate. The files must be named using the subject name's hash and an extension of ".0".
The name of a directory containing the certificates.
Set to indicate what error occurred, if any.
Calls SSL_CTX_load_verify_locations
.
void clear_options( options o); » more... boost::system::error_code clear_options( options o, boost::system::error_code & ec); » more...
Clear options on the context.
void clear_options( options o);
This function may be used to configure the SSL options used by the context.
A bitmask of options. The available option values are defined in
the ssl::context_base
class. The
specified options, if currently enabled on the context, are cleared.
Thrown on failure.
Calls SSL_CTX_clear_options
.
Clear options on the context.
boost::system::error_code clear_options( options o, boost::system::error_code & ec);
This function may be used to configure the SSL options used by the context.
A bitmask of options. The available option values are defined in
the ssl::context_base
class. The
specified options, if currently enabled on the context, are cleared.
Set to indicate what error occurred, if any.
Calls SSL_CTX_clear_options
.
explicit context( method m); » more...
Deprecated constructor taking a reference to an io_service
object.
context( boost::asio::io_service & , method m); » more...
Move-construct a context from another.
context( context && other); » more...
Deprecated constructor taking a reference to an io_service
object.
context( boost::asio::io_service & , method m);
Move-construct a context from another.
context( context && other);
This constructor moves an SSL context from one object to another.
The other context object from which the move will occur.
Following the move, the following operations only are valid for the moved-from object: * Destruction.
(Deprecated: Use native_handle()
.) Get the underlying implementation in
the native type.
impl_type impl();
This function may be used to obtain the underlying implementation of the context. This is intended to allow access to context functionality that is not otherwise provided.
(Deprecated: Use native_handle_type.) The native type of the SSL context.
typedef SSL_CTX * impl_type;
Header: boost/asio/ssl/context.hpp
Convenience header: boost/asio/ssl.hpp
Load a certification authority file for performing verification.
void load_verify_file( const std::string & filename); » more... boost::system::error_code load_verify_file( const std::string & filename, boost::system::error_code & ec); » more...
Load a certification authority file for performing verification.
void load_verify_file( const std::string & filename);
This function is used to load one or more trusted certification authorities from a file.
The name of a file containing certification authority certificates in PEM format.
Thrown on failure.
Calls SSL_CTX_load_verify_locations
.
Load a certification authority file for performing verification.
boost::system::error_code load_verify_file( const std::string & filename, boost::system::error_code & ec);
This function is used to load the certificates for one or more trusted certification authorities from a file.
The name of a file containing certification authority certificates in PEM format.
Set to indicate what error occurred, if any.
Calls SSL_CTX_load_verify_locations
.
Different methods supported by a context.
enum method
Generic SSL version 2.
SSL version 2 client.
SSL version 2 server.
Generic SSL version 3.
SSL version 3 client.
SSL version 3 server.
Generic TLS version 1.
TLS version 1 client.
TLS version 1 server.
Generic SSL/TLS.
SSL/TLS client.
SSL/TLS server.
Generic TLS version 1.1.
TLS version 1.1 client.
TLS version 1.1 server.
Generic TLS version 1.2.
TLS version 1.2 client.
TLS version 1.2 server.
Get the underlying implementation in the native type.
native_handle_type native_handle();
This function may be used to obtain the underlying implementation of the context. This is intended to allow access to context functionality that is not otherwise provided.
The native handle type of the SSL context.
typedef SSL_CTX * native_handle_type;
Header: boost/asio/ssl/context.hpp
Convenience header: boost/asio/ssl.hpp
Disable compression. Compression is disabled by default.
static const long no_compression = implementation_defined;
Move-assign a context from another.
context & operator=( context && other);
This assignment operator moves an SSL context from one object to another.
The other context object from which the move will occur.
Following the move, the following operations only are valid for the moved-from object: * Destruction.
typedef long options;
Header: boost/asio/ssl/context.hpp
Convenience header: boost/asio/ssl.hpp
enum password_purpose
The password is needed for reading/decryption.
The password is needed for writing/encryption.
Configures the context to use the default directories for finding certification authority certificates.
void set_default_verify_paths(); » more... boost::system::error_code set_default_verify_paths( boost::system::error_code & ec); » more...
Configures the context to use the default directories for finding certification authority certificates.
void set_default_verify_paths();
This function specifies that the context should use the default, system-dependent directories for locating certification authority certificates.
Thrown on failure.
Calls SSL_CTX_set_default_verify_paths
.
Configures the context to use the default directories for finding certification authority certificates.
boost::system::error_code set_default_verify_paths( boost::system::error_code & ec);
This function specifies that the context should use the default, system-dependent directories for locating certification authority certificates.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_default_verify_paths
.
void set_options( options o); » more... boost::system::error_code set_options( options o, boost::system::error_code & ec); » more...
Set options on the context.
void set_options( options o);
This function may be used to configure the SSL options used by the context.
A bitmask of options. The available option values are defined in
the ssl::context_base
class. The
options are bitwise-ored with any existing value for the options.
Thrown on failure.
Calls SSL_CTX_set_options
.
Set options on the context.
boost::system::error_code set_options( options o, boost::system::error_code & ec);
This function may be used to configure the SSL options used by the context.
A bitmask of options. The available option values are defined in
the ssl::context_base
class. The
options are bitwise-ored with any existing value for the options.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_options
.
template< typename PasswordCallback> void set_password_callback( PasswordCallback callback); » more... template< typename PasswordCallback> boost::system::error_code set_password_callback( PasswordCallback callback, boost::system::error_code & ec); » more...
Set the password callback.
template< typename PasswordCallback> void set_password_callback( PasswordCallback callback);
This function is used to specify a callback function to obtain password information about an encrypted key in PEM format.
The function object to be used for obtaining the password. The function signature of the handler must be:
std::string password_callback( std::size_t max_length, // The maximum size for a password. password_purpose purpose // Whether password is for reading or writing. );
The return value of the callback is a string containing the password.
Thrown on failure.
Calls SSL_CTX_set_default_passwd_cb
.
Set the password callback.
template< typename PasswordCallback> boost::system::error_code set_password_callback( PasswordCallback callback, boost::system::error_code & ec);
This function is used to specify a callback function to obtain password information about an encrypted key in PEM format.
The function object to be used for obtaining the password. The function signature of the handler must be:
std::string password_callback( std::size_t max_length, // The maximum size for a password. password_purpose purpose // Whether password is for reading or writing. );
The return value of the callback is a string containing the password.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_default_passwd_cb
.
Set the callback used to verify peer certificates.
template< typename VerifyCallback> void set_verify_callback( VerifyCallback callback); » more... template< typename VerifyCallback> boost::system::error_code set_verify_callback( VerifyCallback callback, boost::system::error_code & ec); » more...
Set the callback used to verify peer certificates.
template< typename VerifyCallback> void set_verify_callback( VerifyCallback callback);
This function is used to specify a callback function that will be called by the implementation when it needs to verify a peer certificate.
The function object to be used for verifying a certificate. The function signature of the handler must be:
bool verify_callback( bool preverified, // True if the certificate passed pre-verification. verify_context& ctx // The peer certificate and other context. );
The return value of the callback is true if the certificate has passed verification, false otherwise.
Thrown on failure.
Calls SSL_CTX_set_verify
.
Set the callback used to verify peer certificates.
template< typename VerifyCallback> boost::system::error_code set_verify_callback( VerifyCallback callback, boost::system::error_code & ec);
This function is used to specify a callback function that will be called by the implementation when it needs to verify a peer certificate.
The function object to be used for verifying a certificate. The function signature of the handler must be:
bool verify_callback( bool preverified, // True if the certificate passed pre-verification. verify_context& ctx // The peer certificate and other context. );
The return value of the callback is true if the certificate has passed verification, false otherwise.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_verify
.
Set the peer verification depth.
void set_verify_depth( int depth); » more... boost::system::error_code set_verify_depth( int depth, boost::system::error_code & ec); » more...
Set the peer verification depth.
void set_verify_depth( int depth);
This function may be used to configure the maximum verification depth allowed by the context.
Maximum depth for the certificate chain verification that shall be allowed.
Thrown on failure.
Calls SSL_CTX_set_verify_depth
.
Set the peer verification depth.
boost::system::error_code set_verify_depth( int depth, boost::system::error_code & ec);
This function may be used to configure the maximum verification depth allowed by the context.
Maximum depth for the certificate chain verification that shall be allowed.
Set to indicate what error occurred, if any.
Calls SSL_CTX_set_verify_depth
.
Set the peer verification mode.
void set_verify_mode( verify_mode v); » more... boost::system::error_code set_verify_mode( verify_mode v, boost::system::error_code & ec); » more...
Set the peer verification mode.
void set_verify_mode( verify_mode v);
This function may be used to configure the peer verification mode used by the context.
A bitmask of peer verification modes. See ssl::verify_mode
for available
values.
Thrown on failure.
Calls SSL_CTX_set_verify
.
Set the peer verification mode.