| Home | Libraries | People | FAQ | More

# boost::asio Namespace Reference

## Detailed Description

The boost::asio namespace defines all user-accessible classes and templates.

## Classes

class | basic_datagram_socket
| Provides datagram-oriented socket functionality. More...
class | basic_deadline_timer
| Provides waitable timer functionality. More...
class | basic_io_object
| Base class for all I/O objects. More...
class | basic_resolver
| Provides endpoint resolution functionality. More...
class | basic_socket
| Provides socket functionality. More...
class | basic_socket_acceptor
| Provides the ability to accept new connections. More...
class | basic_socket_iostream
| Iostream interface for a socket. More...
class | basic_socketbuf
| Iostream streambuf for a socket. More...
class | basic_strand
| Provides serialised handler execution. More...
class | basic_stream_socket
| Provides stream-oriented socket functionality. More...
class | basic_streambuf
| Automatically resizable buffer class based on std::streambuf. More...
class | mutable_buffer
| Holds a buffer that can be modified. More...
class | mutable_buffer_container_1
| Adapts a single modifiable buffer so that it meets the requirements of the Mutable_Buffers concept. More...
class | const_buffer
| Holds a buffer that cannot be modified. More...
class | const_buffer_container_1
| Adapts a single non-modifiable buffer so that it meets the requirements of the Const_Buffers concept. More...
class | buffered_read_stream
| Adds buffering to the read-related operations of a stream. More...
class | buffered_stream
| Adds buffering to the read- and write-related operations of a stream. More...
class | buffered_write_stream
| Adds buffering to the write-related operations of a stream. More...
class | datagram_socket_service
| Default service implementation for a datagram socket. More...
class | deadline_timer_service
| Default service implementation for a timer. More...
class | error
| The error class is used to encapsulate system error codes. More...
class | io_service
| Provides core I/O functionality. More...
class | service_already_exists
| Exception thrown when trying to add a duplicate service to an io_service. More...
class | invalid_service_owner
| Exception thrown when trying to add a service object to an io_service where the service has a different owner. More...
class | is_read_buffered
| The is_read_buffered class is a traits class that may be used to determine whether a stream type supports buffering of read data. More...
class | is_write_buffered
| The is_write_buffered class is a traits class that may be used to determine whether a stream type supports buffering of written data. More...
class | resolver_service
| Default service implementation for a resolver. More...
class | socket_acceptor_service
| Default service implementation for a socket acceptor. More...
class | socket_base
| 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. More...
class | strand_service
| Default service implementation for a strand. More...
class | stream_socket_service
| Default service implementation for a stream socket. More...
class | system_exception
| The system_exception class is used to represent system conditions that prevent the library from operating correctly. More...
struct | time_traits< boost::posix_time::ptime >
| Time traits specialised for posix_time. More...

## Namespaces

namespace | placeholders
| The boost::asio::placeholders namespace defines argument placeholders for use with boost::bind.

namespace | ip
| The boost::asio::ip namespace defines the classes associated with IP.

namespace | ssl
| The boost::asio::ssl namespace defines templates and classes for SSL.

## Typedefs

typedef basic_deadline_timer< boost::posix_time::ptime > | deadline_timer
| Typedef for the typical usage of timer.
typedef basic_strand | strand
| Typedef for the typical usage of strand.
typedef basic_streambuf | streambuf
| Typedef for the typical usage of basic_streambuf.

## Functions

mutable_buffer_container_1 | buffer (const mutable_buffer &b)
| Create a new modifiable buffer from an existing buffer.
mutable_buffer_container_1 | buffer (const mutable_buffer &b, std::size_t max_size_in_bytes)
| Create a new modifiable buffer from an existing buffer.
const_buffer_container_1 | buffer (const const_buffer &b)
| Create a new non-modifiable buffer from an existing buffer.
const_buffer_container_1 | buffer (const const_buffer &b, std::size_t max_size_in_bytes)
| Create a new non-modifiable buffer from an existing buffer.
mutable_buffer_container_1 | buffer (void *data, std::size_t size_in_bytes)
| Create a new modifiable buffer that represents the given memory range.
const_buffer_container_1 | buffer (const void *data, std::size_t size_in_bytes)
| Create a new non-modifiable buffer that represents the given memory range.
template<typename Pod_Type, std::size_t N>
mutable_buffer_container_1 | buffer (Pod_Type(&data)[N])
| Create a new modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
mutable_buffer_container_1 | buffer (Pod_Type(&data)[N], std::size_t max_size_in_bytes)
| Create a new modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
const_buffer_container_1 | buffer (const Pod_Type(&data)[N])
| Create a new non-modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
const_buffer_container_1 | buffer (const Pod_Type(&data)[N], std::size_t max_size_in_bytes)
| Create a new non-modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
mutable_buffer_container_1 | buffer (boost::array< Pod_Type, N > &data)
| Create a new modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
mutable_buffer_container_1 | buffer (boost::array< Pod_Type, N > &data, std::size_t max_size_in_bytes)
| Create a new modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
const_buffer_container_1 | buffer (boost::array< const Pod_Type, N > &data)
| Create a new non-modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
const_buffer_container_1 | buffer (boost::array< const Pod_Type, N > &data, std::size_t max_size_in_bytes)
| Create a new non-modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
const_buffer_container_1 | buffer (const boost::array< Pod_Type, N > &data)
| Create a new non-modifiable buffer that represents the given POD array.
template<typename Pod_Type, std::size_t N>
const_buffer_container_1 | buffer (const boost::array< Pod_Type, N > &data, std::size_t max_size_in_bytes)
| Create a new non-modifiable buffer that represents the given POD array.
template<typename Pod_Type, typename Allocator>
mutable_buffer_container_1 | buffer (std::vector< Pod_Type, Allocator > &data)
| Create a new modifiable buffer that represents the given POD vector.
template<typename Pod_Type, typename Allocator>
mutable_buffer_container_1 | buffer (std::vector< Pod_Type, Allocator > &data, std::size_t max_size_in_bytes)
| Create a new modifiable buffer that represents the given POD vector.
template<typename Pod_Type, typename Allocator>
const_buffer_container_1 | buffer (const std::vector< Pod_Type, Allocator > &data)
| Create a new non-modifiable buffer that represents the given POD vector.
template<typename Pod_Type, typename Allocator>
const_buffer_container_1 | buffer (const std::vector< Pod_Type, Allocator > &data, std::size_t max_size_in_bytes)
| Create a new non-modifiable buffer that represents the given POD vector.
const_buffer_container_1 | buffer (const std::string &data)
| Create a new non-modifiable buffer that represents the given string.
const_buffer_container_1 | buffer (const std::string &data, std::size_t max_size_in_bytes)
| Create a new non-modifiable buffer that represents the given string.
unspecified | transfer_all ()
| Return a completion condition function object that indicates that a read or write operation should continue until all of the data has been transferred, or until an error occurs.
unspecified | transfer_at_least (std::size_t minimum)
| Return a completion condition function object that indicates that a read or write operation should continue until a minimum number of bytes has been transferred, or until an error occurs.
unspecified | ignore_error ()
| Return a function object that always ignores the error.
unspecified | throw_error ()
| Return a function object that always throws the error.
template<typename Target>
unspecified | assign_error (Target &target)
| Return a function object that assigns the error to a variable.
void * | asio_handler_allocate (std::size_t size,...)
| Default allocation function for handlers.
void | asio_handler_deallocate (void *pointer, std::size_t size,...)
| Default deallocation function for handlers.
template<typename Sync_Read_Stream, typename Mutable_Buffers>
std::size_t | read (Sync_Read_Stream &s, const Mutable_Buffers &buffers)
| Attempt to read a certain amount of data from a stream before returning.
template<typename Sync_Read_Stream, typename Mutable_Buffers, typename Completion_Condition>
std::size_t | read (Sync_Read_Stream &s, const Mutable_Buffers &buffers, Completion_Condition completion_condition)
| Attempt to read a certain amount of data from a stream before returning.
template<typename Sync_Read_Stream, typename Mutable_Buffers, typename Completion_Condition, typename Error_Handler>
std::size_t | read (Sync_Read_Stream &s, const Mutable_Buffers &buffers, Completion_Condition completion_condition, Error_Handler error_handler)
| Attempt to read a certain amount of data from a stream before returning.
template<typename Sync_Read_Stream, typename Allocator>
std::size_t | read (Sync_Read_Stream &s, basic_streambuf< Allocator > &b)
| Attempt to read a certain amount of data from a stream before returning.
template<typename Sync_Read_Stream, typename Allocator, typename Completion_Condition>
std::size_t | read (Sync_Read_Stream &s, basic_streambuf< Allocator > &b, Completion_Condition completion_condition)
| Attempt to read a certain amount of data from a stream before returning.
template<typename Sync_Read_Stream, typename Allocator, typename Completion_Condition, typename Error_Handler>
std::size_t | read (Sync_Read_Stream &s, basic_streambuf< Allocator > &b, Completion_Condition completion_condition, Error_Handler error_handler)
| Attempt to read a certain amount of data from a stream before returning.
template<typename Async_Read_Stream, typename Mutable_Buffers, typename Handler>
void | async_read (Async_Read_Stream &s, const Mutable_Buffers &buffers, Handler handler)
| Start an asynchronous operation to read a certain amount of data from a stream.
template<typename Async_Read_Stream, typename Mutable_Buffers, typename Completion_Condition, typename Handler>
void | async_read (Async_Read_Stream &s, const Mutable_Buffers &buffers, Completion_Condition completion_condition, Handler handler)
| Start an asynchronous operation to read a certain amount of data from a stream.
template<typename Async_Read_Stream, typename Allocator, typename Handler>
void | async_read (Async_Read_Stream &s, basic_streambuf< Allocator > &b, Handler handler)
| Start an asynchronous operation to read a certain amount of data from a stream.
template<typename Async_Read_Stream, typename Allocator, typename Completion_Condition, typename Handler>
void | async_read (Async_Read_Stream &s, basic_streambuf< Allocator > &b, Completion_Condition completion_condition, Handler handler)
| Start an asynchronous operation to read a certain amount of data from a stream.
template<typename Sync_Read_Stream, typename Allocator>
std::size_t | read_until (Sync_Read_Stream &s, boost::asio::basic_streambuf< Allocator > &b, char delim)
| Read data into a streambuf until a delimiter is encountered.
template<typename Sync_Read_Stream, typename Allocator, typename Error_Handler>
std::size_t | read_until (Sync_Read_Stream &s, boost::asio::basic_streambuf< Allocator > &b, char delim, Error_Handler error_handler)
| Read data into a streambuf until a delimiter is encountered.
template<typename Sync_Read_Stream, typename Allocator>
std::size_t | read_until (Sync_Read_Stream &s, boost::asio::basic_streambuf< Allocator > &b, const boost::regex &expr)
| Read data into a streambuf until a regular expression is located.
template<typename Sync_Read_Stream, typename Allocator, typename Error_Handler>
std::size_t | read_until (Sync_Read_Stream &s, boost::asio::basic_streambuf< Allocator > &b, const boost::regex &expr, Error_Handler error_handler)
| Read data into a streambuf until a regular expression is located.
template<typename Async_Read_Stream, typename Allocator, typename Handler>
void | async_read_until (Async_Read_Stream &s, boost::asio::basic_streambuf< Allocator > &b, char delim, Handler handler)
| Start an asynchronous operation to read data into a streambuf until a delimiter is encountered.
template<typename Async_Read_Stream, typename Allocator, typename Handler>
void | async_read_until (Async_Read_Stream &s, boost::asio::basic_streambuf< Allocator > &b, const boost::regex &expr, Handler handler)
| Start an asynchronous operation to read data into a streambuf until a regular expression is located.
template<typename Sync_Write_Stream, typename Const_Buffers>
std::size_t | write (Sync_Write_Stream &s, const Const_Buffers &buffers)
| Write all of the supplied data to a stream before returning.
template<typename Sync_Write_Stream, typename Const_Buffers, typename Completion_Condition>
std::size_t | write (Sync_Write_Stream &s, const Const_Buffers &buffers, Completion_Condition completion_condition)
| Write a certain amount of data to a stream before returning.
template<typename Sync_Write_Stream, typename Const_Buffers, typename Completion_Condition, typename Error_Handler>
std::size_t | write (Sync_Write_Stream &s, const Const_Buffers &buffers, Completion_Condition completion_condition, Error_Handler error_handler)
| Write a certain amount of data to a stream before returning.
template<typename Sync_Write_Stream, typename Allocator>
std::size_t | write (Sync_Write_Stream &s, basic_streambuf< Allocator > &b)
| Write a certain amount of data to a stream before returning.
template<typename Sync_Write_Stream, typename Allocator, typename Completion_Condition>
std::size_t | write (Sync_Write_Stream &s, basic_streambuf< Allocator > &b, Completion_Condition completion_condition)
| Write a certain amount of data to a stream before returning.
template<typename Sync_Write_Stream, typename Allocator, typename Completion_Condition, typename Error_Handler>
std::size_t | write (Sync_Write_Stream &s, basic_streambuf< Allocator > &b, Completion_Condition completion_condition, Error_Handler error_handler)
| Write a certain amount of data to a stream before returning.
template<typename Async_Write_Stream, typename Const_Buffers, typename Handler>
void | async_write (Async_Write_Stream &s, const Const_Buffers &buffers, Handler handler)
| Start an asynchronous operation to write of all of the supplied data to a stream.
template<typename Async_Write_Stream, typename Const_Buffers, typename Completion_Condition, typename Handler>
void | async_write (Async_Write_Stream &s, const Const_Buffers &buffers, Completion_Condition completion_condition, Handler handler)
| Start an asynchronous operation to write a certain amount of data to a stream.
template<typename Async_Write_Stream, typename Allocator, typename Handler>
void | async_write (Async_Write_Stream &s, basic_streambuf< Allocator > &b, Handler handler)
| Start an asynchronous operation to write a certain amount of data to a stream.
template<typename Async_Write_Stream, typename Allocator, typename Completion_Condition, typename Handler>
void | async_write (Async_Write_Stream &s, basic_streambuf< Allocator > &b, Completion_Condition completion_condition, Handler handler)
| Start an asynchronous operation to write a certain amount of data to a stream.
template<typename Service>
Service & | use_service (io_service &ios)
template<typename Service>
void | add_service (io_service &ios, Service *svc)
template<typename Service>
bool | has_service (io_service &ios)

## Typedef Documentation

typedef basic_deadline_timer<boost::posix_time::ptime> boost::asio::deadline_timer

Typedef for the typical usage of timer.

typedef basic_strand boost::asio::strand

Typedef for the typical usage of strand.

typedef basic_streambuf boost::asio::streambuf

Typedef for the typical usage of basic_streambuf.

## Function Documentation

void* boost::asio::asio_handler_allocate | ( | std::size_t | size,
|  |  | ... |
| ) |  |  |

Default allocation function for handlers.

Asynchronous operations may need to allocate temporary objects. Since asynchronous operations have a handler function object, these temporary objects can be said to be associated with the handler.

Implement asio_handler_allocate and asio_handler_deallocate for your own handlers to provide custom allocation for these temporary objects.

This default implementation is simply:

     return ::operator new(bytes);

Note:
  All temporary objects associated with a handler will be deallocated before the upcall to the handler is performed. This allows the same memory to be reused for a subsequent asynchronous operation initiated by the handler.

Example:

       class my_handler;

       void* asio_handler_allocate(std::size_t size, my_handler* context)
       {
         return ::operator new(size);
       }

       void asio_handler_deallocate(void* pointer, std::size_t size,
           my_handler* context)
       {
         ::operator delete(pointer);
       }

void boost::asio::asio_handler_deallocate | ( | void * | pointer,
|  | std::size_t | size,
|  |  | ... |
| ) |  |  |

Default deallocation function for handlers.

Implement asio_handler_allocate and asio_handler_deallocate for your own handlers to provide custom allocation for the associated temporary objects.

This default implementation is simply:

     ::operator delete(pointer);

See also:
  asio_handler_allocate.

template<typename Service>

Service& boost::asio::use_service | ( | io_service & | ios | ) |

This function is used to locate a service object that corresponds to the given service type. If there is no existing implementation of the service, then the io_service will create a new instance of the service.

Parameters:

  | ios | The io_service object that owns the service.

Returns:
  The service interface implementing the specified service type. Ownership of the service interface is not transferred to the caller.

template<typename Service>

void boost::asio::add_service | ( | io_service & | ios,
|  | Service * | svc |
| ) |  |  |

This function is used to add a service to the io_service.

Parameters:

  | ios | The io_service object that owns the service.
  | svc | The service object. On success, ownership of the service object is transferred to the io_service. When the io_service object is destroyed, it will destroy the service object by performing:
       delete static_cast<io_service::service*>(svc)

Exceptions:

  | boost::asio::service_already_exists | Thrown if a service of the given type is already present in the io_service.
  | boost::asio::invalid_service_owner | Thrown if the service's owning io_service is not the io_service object specified by the ios parameter.

template<typename Service>

bool boost::asio::has_service | ( | io_service & | ios | ) |

This function is used to determine whether the io_service contains a service object corresponding to the given service type.

Parameters:

  | ios | The io_service object that owns the service.

Returns:
  A boolean indicating whether the io_service contains the service.

| Copyright © 2003 - 2006 Christopher M. Kohlhoff