asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design
Reference Class Hierarchy | Class Index | Member Index

asio Namespace Reference


Detailed Description

The 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_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_socket_streambuf
 Iostream streambuf for a socket. 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_buffers_1
 Adapts a single modifiable buffer so that it meets the requirements of the MutableBufferSequence concept. More...
class  const_buffer
 Holds a buffer that cannot be modified. More...
class  const_buffers_1
 Adapts a single non-modifiable buffer so that it meets the requirements of the ConstBufferSequence 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
 Contains error constants. More...
class  error_code
 Class to represent an error code value. 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  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  stream_socket_service
 Default service implementation for a stream socket. More...
class  system_error
 The system_error class is used to represent system conditions that prevent the library from operating correctly. More...
class  thread
 A simple abstraction for starting threads. More...
struct  time_traits< boost::posix_time::ptime >
 Time traits specialised for posix_time. More...

Namespaces

namespace  placeholders
 The asio::placeholders namespace defines argument placeholders for use with boost::bind.
namespace  ip
 The asio::ip namespace defines the classes associated with IP.
namespace  ssl
 The 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 asio::io_service::strand strand
 Typedef for backwards compatibility.
typedef basic_streambuf streambuf
 Typedef for the typical usage of basic_streambuf.

Enumerations

enum  error_category {
  native_ecat = ASIO_WIN_OR_POSIX(0, 0),
  netdb_ecat = ASIO_WIN_OR_POSIX(native_ecat, 1),
  addrinfo_ecat = ASIO_WIN_OR_POSIX(native_ecat, 2),
  misc_ecat = ASIO_WIN_OR_POSIX(3, 3),
  ssl_ecat = ASIO_WIN_OR_POSIX(4, 4)
}
 Available error code categories. More...

Functions

mutable_buffers_1 buffer (const mutable_buffer &b)
 Create a new modifiable buffer from an existing buffer.
mutable_buffers_1 buffer (const mutable_buffer &b, std::size_t max_size_in_bytes)
 Create a new modifiable buffer from an existing buffer.
const_buffers_1 buffer (const const_buffer &b)
 Create a new non-modifiable buffer from an existing buffer.
const_buffers_1 buffer (const const_buffer &b, std::size_t max_size_in_bytes)
 Create a new non-modifiable buffer from an existing buffer.
mutable_buffers_1 buffer (void *data, std::size_t size_in_bytes)
 Create a new modifiable buffer that represents the given memory range.
const_buffers_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 PodType, std::size_t N>
mutable_buffers_1 buffer (PodType(&data)[N])
 Create a new modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
mutable_buffers_1 buffer (PodType(&data)[N], std::size_t max_size_in_bytes)
 Create a new modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
const_buffers_1 buffer (const PodType(&data)[N])
 Create a new non-modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
const_buffers_1 buffer (const PodType(&data)[N], std::size_t max_size_in_bytes)
 Create a new non-modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
mutable_buffers_1 buffer (boost::array< PodType, N > &data)
 Create a new modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
mutable_buffers_1 buffer (boost::array< PodType, N > &data, std::size_t max_size_in_bytes)
 Create a new modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
const_buffers_1 buffer (boost::array< const PodType, N > &data)
 Create a new non-modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
const_buffers_1 buffer (boost::array< const PodType, N > &data, std::size_t max_size_in_bytes)
 Create a new non-modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
const_buffers_1 buffer (const boost::array< PodType, N > &data)
 Create a new non-modifiable buffer that represents the given POD array.
template<typename PodType, std::size_t N>
const_buffers_1 buffer (const boost::array< PodType, N > &data, std::size_t max_size_in_bytes)
 Create a new non-modifiable buffer that represents the given POD array.
template<typename PodType, typename Allocator>
mutable_buffers_1 buffer (std::vector< PodType, Allocator > &data)
 Create a new modifiable buffer that represents the given POD vector.
template<typename PodType, typename Allocator>
mutable_buffers_1 buffer (std::vector< PodType, Allocator > &data, std::size_t max_size_in_bytes)
 Create a new modifiable buffer that represents the given POD vector.
template<typename PodType, typename Allocator>
const_buffers_1 buffer (const std::vector< PodType, Allocator > &data)
 Create a new non-modifiable buffer that represents the given POD vector.
template<typename PodType, typename Allocator>
const_buffers_1 buffer (const std::vector< PodType, Allocator > &data, std::size_t max_size_in_bytes)
 Create a new non-modifiable buffer that represents the given POD vector.
const_buffers_1 buffer (const std::string &data)
 Create a new non-modifiable buffer that represents the given string.
const_buffers_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.
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 Function>
void asio_handler_invoke (Function function,...)
 Default invoke function for handlers.
template<typename SyncReadStream, typename MutableBufferSequence>
std::size_t read (SyncReadStream &s, const MutableBufferSequence &buffers)
 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)
 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, asio::error_code &ec)
 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)
 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)
 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, asio::error_code &ec)
 Attempt to read a certain amount of data from a stream before returning.
template<typename AsyncReadStream, typename MutableBufferSequence, typename ReadHandler>
void async_read (AsyncReadStream &s, const MutableBufferSequence &buffers, ReadHandler handler)
 Start an asynchronous operation to read a certain amount of data from a stream.
template<typename AsyncReadStream, typename MutableBufferSequence, typename CompletionCondition, typename ReadHandler>
void async_read (AsyncReadStream &s, const MutableBufferSequence &buffers, CompletionCondition completion_condition, ReadHandler handler)
 Start an asynchronous operation to read a certain amount of data from a stream.
template<typename AsyncReadStream, typename Allocator, typename ReadHandler>
void async_read (AsyncReadStream &s, basic_streambuf< Allocator > &b, ReadHandler handler)
 Start an asynchronous operation to read a certain amount of data from a stream.
template<typename AsyncReadStream, typename Allocator, typename CompletionCondition, typename ReadHandler>
void async_read (AsyncReadStream &s, basic_streambuf< Allocator > &b, CompletionCondition completion_condition, ReadHandler handler)
 Start an asynchronous operation to read a certain amount of data from a stream.
template<typename SyncReadStream, typename Allocator>
std::size_t read_until (SyncReadStream &s, asio::basic_streambuf< Allocator > &b, char delim)
 Read data into a streambuf until a delimiter is encountered.
template<typename SyncReadStream, typename Allocator>
std::size_t read_until (SyncReadStream &s, asio::basic_streambuf< Allocator > &b, char delim, asio::error_code &ec)
 Read data into a streambuf until a delimiter is encountered.
template<typename SyncReadStream, typename Allocator>
std::size_t read_until (SyncReadStream &s, asio::basic_streambuf< Allocator > &b, const std::string &delim)
 Read data into a streambuf until a delimiter is encountered.
template<typename SyncReadStream, typename Allocator>
std::size_t read_until (SyncReadStream &s, asio::basic_streambuf< Allocator > &b, const std::string &delim, asio::error_code &ec)
 Read data into a streambuf until a delimiter is encountered.
template<typename SyncReadStream, typename Allocator>
std::size_t read_until (SyncReadStream &s, asio::basic_streambuf< Allocator > &b, const boost::regex &expr)
 Read data into a streambuf until a regular expression is located.
template<typename SyncReadStream, typename Allocator>
std::size_t read_until (SyncReadStream &s, asio::basic_streambuf< Allocator > &b, const boost::regex &expr, asio::error_code &ec)
 Read data into a streambuf until a regular expression is located.
template<typename AsyncReadStream, typename Allocator, typename ReadHandler>
void async_read_until (AsyncReadStream &s, asio::basic_streambuf< Allocator > &b, char delim, ReadHandler handler)
 Start an asynchronous operation to read data into a streambuf until a delimiter is encountered.
template<typename AsyncReadStream, typename Allocator, typename ReadHandler>
void async_read_until (AsyncReadStream &s, asio::basic_streambuf< Allocator > &b, const std::string &delim, ReadHandler handler)
 Start an asynchronous operation to read data into a streambuf until a delimiter is encountered.
template<typename AsyncReadStream, typename Allocator, typename ReadHandler>
void async_read_until (AsyncReadStream &s, asio::basic_streambuf< Allocator > &b, const boost::regex &expr, ReadHandler handler)
 Start an asynchronous operation to read data into a streambuf until a regular expression is located.
template<typename SyncWriteStream, typename ConstBufferSequence>
std::size_t write (SyncWriteStream &s, const ConstBufferSequence &buffers)
 Write all of the supplied data to a stream before returning.
template<typename SyncWriteStream, typename ConstBufferSequence, typename CompletionCondition>
std::size_t write (SyncWriteStream &s, const ConstBufferSequence &buffers, CompletionCondition completion_condition)
 Write a certain amount of data to a stream before returning.
template<typename SyncWriteStream, typename ConstBufferSequence, typename CompletionCondition>
std::size_t write (SyncWriteStream &s, const ConstBufferSequence &buffers, CompletionCondition completion_condition, asio::error_code &ec)
 Write a certain amount of data to a stream before returning.
template<typename SyncWriteStream, typename Allocator>
std::size_t write (SyncWriteStream &s, basic_streambuf< Allocator > &b)
 Write a certain amount of data to a stream before returning.
template<typename SyncWriteStream, typename Allocator, typename CompletionCondition>
std::size_t write (SyncWriteStream &s, basic_streambuf< Allocator > &b, CompletionCondition completion_condition)
 Write a certain amount of data to a stream before returning.
template<typename SyncWriteStream, typename Allocator, typename CompletionCondition>
std::size_t write (SyncWriteStream &s, basic_streambuf< Allocator > &b, CompletionCondition completion_condition, asio::error_code &ec)
 Write a certain amount of data to a stream before returning.
template<typename AsyncWriteStream, typename ConstBufferSequence, typename WriteHandler>
void async_write (AsyncWriteStream &s, const ConstBufferSequence &buffers, WriteHandler handler)
 Start an asynchronous operation to write of all of the supplied data to a stream.
template<typename AsyncWriteStream, typename ConstBufferSequence, typename CompletionCondition, typename WriteHandler>
void async_write (AsyncWriteStream &s, const ConstBufferSequence &buffers, CompletionCondition completion_condition, WriteHandler handler)
 Start an asynchronous operation to write a certain amount of data to a stream.
template<typename AsyncWriteStream, typename Allocator, typename WriteHandler>
void async_write (AsyncWriteStream &s, basic_streambuf< Allocator > &b, WriteHandler handler)
 Start an asynchronous operation to write a certain amount of data to a stream.
template<typename AsyncWriteStream, typename Allocator, typename CompletionCondition, typename WriteHandler>
void async_write (AsyncWriteStream &s, basic_streambuf< Allocator > &b, CompletionCondition completion_condition, WriteHandler 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> asio::deadline_timer

Typedef for the typical usage of timer.

typedef asio::io_service::strand asio::strand

Typedef for backwards compatibility.

typedef basic_streambuf asio::streambuf

Typedef for the typical usage of basic_streambuf.


Enumeration Type Documentation

enum asio::error_category

Available error code categories.

Enumerator:
native_ecat  Native error codes.
netdb_ecat  Error codes from NetDB functions.
addrinfo_ecat  Error codes from getaddrinfo.
misc_ecat  Miscellaneous error codes.
ssl_ecat  SSL error codes.


Function Documentation

void* 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 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 Function>
void asio::asio_handler_invoke ( Function  function,
  ... 
)

Default invoke function for handlers.

Completion handlers for asynchronous operations are invoked by the io_service associated with the corresponding object (e.g. a socket or deadline_timer). Certain guarantees are made on when the handler may be invoked, in particular that a handler can only be invoked from a thread that is currently calling asio::io_service::run() on the corresponding io_service object. Handlers may subsequently be invoked through other objects (such as asio::strand objects) that provide additional guarantees.

When asynchronous operations are composed from other asynchronous operations, all intermediate handlers should be invoked using the same method as the final handler. This is required to ensure that user-defined objects are not accessed in a way that may violate the guarantees. This hooking function ensures that the invoked method used for the final handler is accessible at each intermediate step.

Implement asio_handler_invoke for your own handlers to specify a custom invocation strategy.

This default implementation is simply:

 function();

Example
 class my_handler;

 template <typename Function>
 void asio_handler_invoke(Function function, my_handler* context)
 {
   context->strand_.dispatch(function);
 }

template<typename Service>
Service& 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 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:
asio::service_already_exists Thrown if a service of the given type is already present in the io_service.
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 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.

asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design