| Home | Libraries | People | FAQ | More

# services::stream_socket_service< Protocol > Class Template Reference

Inherits boost::asio::io_service::service.

Collaboration diagram for services::stream_socket_service< Protocol >:

List of all members.

## Detailed Description

### template<typename Protocol>
class services::stream_socket_service< Protocol >

Debugging stream socket service that wraps the normal stream socket service.

Definition at line 13 of file stream_socket_service.hpp.

## Public Types

typedef Protocol | protocol_type
| The protocol type.
typedef Protocol::endpoint | endpoint_type
| The endpoint type.
typedef service_impl_type::implementation_type | implementation_type
| The implementation type of a stream socket.
typedef service_impl_type::native_type | native_type
| The native type of a stream socket.

## Public Member Functions

| stream_socket_service (boost::asio::io_service &io_service)
| Construct a new stream socket service for the specified io_service.
void | shutdown_service ()
| Destroy all user-defined handler objects owned by the service.
void | construct (implementation_type &impl)
| Construct a new stream socket implementation.
void | destroy (implementation_type &impl)
| Destroy a stream socket implementation.
template<typename Error_Handler>
void | open (implementation_type &impl, const protocol_type &protocol, Error_Handler error_handler)
| Open a new stream socket implementation.
template<typename Error_Handler>
void | open (implementation_type &impl, const native_type &native_socket, Error_Handler error_handler)
| Open a stream socket from an existing native socket.
template<typename Error_Handler>
void | close (implementation_type &impl, Error_Handler error_handler)
| Close a stream socket implementation.
template<typename Error_Handler>
void | bind (implementation_type &impl, const endpoint_type &endpoint, Error_Handler error_handler)
| Bind the stream socket to the specified local endpoint.
template<typename Error_Handler>
void | connect (implementation_type &impl, const endpoint_type &peer_endpoint, Error_Handler error_handler)
| Connect the stream socket to the specified endpoint.
template<typename Handler>
void | async_connect (implementation_type &impl, const endpoint_type &peer_endpoint, Handler handler)
| Start an asynchronous connect.
template<typename Option, typename Error_Handler>
void | set_option (implementation_type &impl, const Option &option, Error_Handler error_handler)
| Set a socket option.
template<typename Option, typename Error_Handler>
void | get_option (const implementation_type &impl, Option &option, Error_Handler error_handler) const
| Get a socket option.
template<typename IO_Control_Command, typename Error_Handler>
void | io_control (implementation_type &impl, IO_Control_Command &command, Error_Handler error_handler)
| Perform an IO control command on the socket.
template<typename Error_Handler>
void | local_endpoint (const implementation_type &impl, Error_Handler error_handler) const
| Get the local endpoint.
template<typename Error_Handler>
endpoint_type | remote_endpoint (const implementation_type &impl, Error_Handler error_handler) const
| Get the remote endpoint.
template<typename Error_Handler>
void | shutdown (implementation_type &impl, boost::asio::socket_base::shutdown_type what, Error_Handler error_handler)
| Disable sends or receives on the socket.
template<typename Const_Buffers, typename Error_Handler>
std::size_t | send (implementation_type &impl, const Const_Buffers &buffers, boost::asio::socket_base::message_flags flags, Error_Handler error_handler)
| Send the given data to the peer.
template<typename Const_Buffers, typename Handler>
void | async_send (implementation_type &impl, const Const_Buffers &buffers, boost::asio::socket_base::message_flags flags, Handler handler)
| Start an asynchronous send.
template<typename Mutable_Buffers, typename Error_Handler>
std::size_t | receive (implementation_type &impl, const Mutable_Buffers &buffers, boost::asio::socket_base::message_flags flags, Error_Handler error_handler)
| Receive some data from the peer.
template<typename Mutable_Buffers, typename Handler>
void | async_receive (implementation_type &impl, const Mutable_Buffers &buffers, boost::asio::socket_base::message_flags flags, Handler handler)
| Start an asynchronous receive.

## Private Types

typedef boost::asio::stream_socket_service< Protocol > | service_impl_type
| The type of the wrapped stream socket service.

## Private Attributes

service_impl_type & | service_impl_
| The wrapped stream socket service.
logger | logger_
| The logger used for writing debug messages.

## Classes

class | connect_handler
| Handler to wrap asynchronous connect completion. More...
class | receive_handler
| Handler to wrap asynchronous receive completion. More...
class | send_handler
| Handler to wrap asynchronous send completion. More...

## Member Typedef Documentation

template<typename Protocol>

typedef boost::asio::stream_socket_service<Protocol> services::stream_socket_service< Protocol >::service_impl_type `[private]`

The type of the wrapped stream socket service.

Definition at line 18 of file stream_socket_service.hpp.

template<typename Protocol>

typedef Protocol services::stream_socket_service< Protocol >::protocol_type

The protocol type.

Definition at line 22 of file stream_socket_service.hpp.

template<typename Protocol>

typedef Protocol::endpoint services::stream_socket_service< Protocol >::endpoint_type

The endpoint type.

Definition at line 25 of file stream_socket_service.hpp.

template<typename Protocol>

typedef service_impl_type::implementation_type services::stream_socket_service< Protocol >::implementation_type

The implementation type of a stream socket.

Definition at line 28 of file stream_socket_service.hpp.

template<typename Protocol>

typedef service_impl_type::native_type services::stream_socket_service< Protocol >::native_type

The native type of a stream socket.

Definition at line 31 of file stream_socket_service.hpp.

## Constructor & Destructor Documentation

template<typename Protocol>

services::stream_socket_service< Protocol >::stream_socket_service | ( | boost::asio::io_service & | io_service | ) | `[explicit]`

Construct a new stream socket service for the specified io_service.

Definition at line 34 of file stream_socket_service.hpp.

    00035     : boost::asio::io_service::service(io_service),
    00036       service_impl_(boost::asio::use_service<service_impl_type>(io_service)),
    00037       logger_(io_service, "stream_socket")
    00038   {
    00039   }

## Member Function Documentation

template<typename Protocol>

void services::stream_socket_service< Protocol >::shutdown_service | ( |  | ) | `[virtual]`

Destroy all user-defined handler objects owned by the service.

Implements boost::asio::io_service::service.

Definition at line 42 of file stream_socket_service.hpp.

    00043   {
    00044   }

template<typename Protocol>

void services::stream_socket_service< Protocol >::construct | ( | implementation_type & | impl | ) |

Construct a new stream socket implementation.

Definition at line 47 of file stream_socket_service.hpp.

    00048   {
    00049     service_impl_.construct(impl);
    00050   }

template<typename Protocol>

void services::stream_socket_service< Protocol >::destroy | ( | implementation_type & | impl | ) |

Destroy a stream socket implementation.

Definition at line 53 of file stream_socket_service.hpp.

    00054   {
    00055     service_impl_.destroy(impl);
    00056   }

template<typename Protocol>
template<typename Error_Handler>

void services::stream_socket_service< Protocol >::open | ( | implementation_type & | impl,
|  | const protocol_type & | protocol,
|  | Error_Handler | error_handler |
| ) |  |  |

Open a new stream socket implementation.

Definition at line 60 of file stream_socket_service.hpp.

    00062   {
    00063     logger_.log("Opening new socket");
    00064     service_impl_.open(impl, protocol, error_handler);
    00065   }

template<typename Protocol>
template<typename Error_Handler>

void services::stream_socket_service< Protocol >::open | ( | implementation_type & | impl,
|  | const native_type & | native_socket,
|  | Error_Handler | error_handler |
| ) |  |  |

Open a stream socket from an existing native socket.

Definition at line 69 of file stream_socket_service.hpp.

    00071   {
    00072     logger_.log("Opening native socket");
    00073     service_impl_.open(impl, native_socket, error_handler);
    00074   }

template<typename Protocol>
template<typename Error_Handler>

void services::stream_socket_service< Protocol >::close | ( | implementation_type & | impl,
|  | Error_Handler | error_handler |
| ) |  |  |

Close a stream socket implementation.

Definition at line 78 of file stream_socket_service.hpp.

    00079   {
    00080     logger_.log("Closing socket");
    00081     service_impl_.close(impl, error_handler);
    00082   }

template<typename Protocol>
template<typename Error_Handler>

void services::stream_socket_service< Protocol >::bind | ( | implementation_type & | impl,
|  | const endpoint_type & | endpoint,
|  | Error_Handler | error_handler |
| ) |  |  |

Bind the stream socket to the specified local endpoint.

Definition at line 86 of file stream_socket_service.hpp.

    00088   {
    00089     logger_.log("Binding socket");
    00090     service_impl_.bind(impl, endpoint, error_handler);
    00091   }

template<typename Protocol>
template<typename Error_Handler>

void services::stream_socket_service< Protocol >::connect | ( | implementation_type & | impl,
|  | const endpoint_type & | peer_endpoint,
|  | Error_Handler | error_handler |
| ) |  |  |

Connect the stream socket to the specified endpoint.

Definition at line 95 of file stream_socket_service.hpp.

    00097   {
    00098     logger_.log("Connecting socket to " +
    00099         boost::lexical_cast<std::string>(peer_endpoint));
    00100     service_impl_.connect(impl, peer_endpoint, error_handler);
    00101   }

template<typename Protocol>
template<typename Handler>

void services::stream_socket_service< Protocol >::async_connect | ( | implementation_type & | impl,
|  | const endpoint_type & | peer_endpoint,
|  | Handler | handler |
| ) |  |  |

Start an asynchronous connect.

Definition at line 137 of file stream_socket_service.hpp.

    00139   {
    00140     logger_.log("Starting asynchronous connect to " +
    00141         boost::lexical_cast<std::string>(peer_endpoint));
    00142     service_impl_.async_connect(impl, peer_endpoint,
    00143         connect_handler<Handler>(handler, logger_));
    00144   }

template<typename Protocol>
template<typename Option, typename Error_Handler>

void services::stream_socket_service< Protocol >::set_option | ( | implementation_type & | impl,
|  | const Option & | option,
|  | Error_Handler | error_handler |
| ) |  |  |

Set a socket option.

Definition at line 148 of file stream_socket_service.hpp.

    00150   {
    00151     logger_.log("Setting socket option");
    00152     service_impl_.set_option(impl, option, error_handler);
    00153   }

template<typename Protocol>
template<typename Option, typename Error_Handler>

void services::stream_socket_service< Protocol >::get_option | ( | const implementation_type & | impl,
|  | Option & | option,
|  | Error_Handler | error_handler |
| ) |  |  | const

Get a socket option.

Definition at line 157 of file stream_socket_service.hpp.

    00159   {
    00160     logger_.log("Getting socket option");
    00161     service_impl_.get_option(impl, option, error_handler);
    00162   }

template<typename Protocol>
template<typename IO_Control_Command, typename Error_Handler>

void services::stream_socket_service< Protocol >::io_control | ( | implementation_type & | impl,
|  | IO_Control_Command & | command,
|  | Error_Handler | error_handler |
| ) |  |  |

Perform an IO control command on the socket.

Definition at line 166 of file stream_socket_service.hpp.

    00168   {
    00169     logger_.log("Performing IO control command on socket");
    00170     service_impl_.io_control(impl, command, error_handler);
    00171   }

template<typename Protocol>
template<typename Error_Handler>

void services::stream_socket_service< Protocol >::local_endpoint | ( | const implementation_type & | impl,
|  | Error_Handler | error_handler |
| ) |  |  | const

Get the local endpoint.

Definition at line 175 of file stream_socket_service.hpp.

    00177   {
    00178     logger_.log("Getting socket's local endpoint");
    00179     return service_impl_.local_endpoint(impl, error_handler);
    00180   }

template<typename Protocol>
template<typename Error_Handler>

endpoint_type services::stream_socket_service< Protocol >::remote_endpoint | ( | const implementation_type & | impl,
|  | Error_Handler | error_handler |
| ) |  |  | const

Get the remote endpoint.

Definition at line 184 of file stream_socket_service.hpp.

    00186   {
    00187     logger_.log("Getting socket's remote endpoint");
    00188     return service_impl_.remote_endpoint(impl, error_handler);
    00189   }

template<typename Protocol>
template<typename Error_Handler>

void services::stream_socket_service< Protocol >::shutdown | ( | implementation_type & | impl,
|  | boost::asio::socket_base::shutdown_type | what,
|  | Error_Handler | error_handler |
| ) |  |  |

Disable sends or receives on the socket.

Definition at line 193 of file stream_socket_service.hpp.

    00195   {
    00196     logger_.log("Shutting down socket");
    00197     service_impl_.shutdown(impl, what, error_handler);
    00198   }

template<typename Protocol>
template<typename Const_Buffers, typename Error_Handler>

std::size_t services::stream_socket_service< Protocol >::send | ( | implementation_type & | impl,
|  | const Const_Buffers & | buffers,
|  | boost::asio::socket_base::message_flags | flags,
|  | Error_Handler | error_handler |
| ) |  |  |

Send the given data to the peer.

Definition at line 202 of file stream_socket_service.hpp.

    00205   {
    00206     logger_.log("Sending data on socket");
    00207     return service_impl_.send(impl, buffers, flags, error_handler);
    00208   }

template<typename Protocol>
template<typename Const_Buffers, typename Handler>

void services::stream_socket_service< Protocol >::async_send | ( | implementation_type & | impl,
|  | const Const_Buffers & | buffers,
|  | boost::asio::socket_base::message_flags | flags,
|  | Handler | handler |
| ) |  |  |

Start an asynchronous send.

Definition at line 244 of file stream_socket_service.hpp.

    00246   {
    00247     logger_.log("Starting asynchronous send");
    00248     service_impl_.async_send(impl, buffers, flags,
    00249         send_handler<Handler>(handler, logger_));
    00250   }

template<typename Protocol>
template<typename Mutable_Buffers, typename Error_Handler>

std::size_t services::stream_socket_service< Protocol >::receive | ( | implementation_type & | impl,
|  | const Mutable_Buffers & | buffers,
|  | boost::asio::socket_base::message_flags | flags,
|  | Error_Handler | error_handler |
| ) |  |  |

Receive some data from the peer.

Definition at line 254 of file stream_socket_service.hpp.

    00257   {
    00258     logger_.log("Receiving data on socket");
    00259     return service_impl_.receive(impl, buffers, flags, error_handler);
    00260   }

template<typename Protocol>
template<typename Mutable_Buffers, typename Handler>

void services::stream_socket_service< Protocol >::async_receive | ( | implementation_type & | impl,
|  | const Mutable_Buffers & | buffers,
|  | boost::asio::socket_base::message_flags | flags,
|  | Handler | handler |
| ) |  |  |

Start an asynchronous receive.

Definition at line 296 of file stream_socket_service.hpp.

    00298   {
    00299     logger_.log("Starting asynchronous receive");
    00300     service_impl_.async_receive(impl, buffers, flags,
    00301         receive_handler<Handler>(handler, logger_));
    00302   }

## Member Data Documentation

template<typename Protocol>

service_impl_type& services::stream_socket_service< Protocol >::service_impl_ `[private]`

The wrapped stream socket service.

Definition at line 306 of file stream_socket_service.hpp.

Referenced by services::stream_socket_service< Protocol >::async_connect(), services::stream_socket_service< Protocol >::async_receive(), services::stream_socket_service< Protocol >::async_send(), services::stream_socket_service< Protocol >::bind(), services::stream_socket_service< Protocol >::close(), services::stream_socket_service< Protocol >::connect(), services::stream_socket_service< Protocol >::construct(), services::stream_socket_service< Protocol >::destroy(), services::stream_socket_service< Protocol >::get_option(), services::stream_socket_service< Protocol >::io_control(), services::stream_socket_service< Protocol >::local_endpoint(), services::stream_socket_service< Protocol >::open(), services::stream_socket_service< Protocol >::receive(), services::stream_socket_service< Protocol >::remote_endpoint(), services::stream_socket_service< Protocol >::send(), services::stream_socket_service< Protocol >::set_option(), and services::stream_socket_service< Protocol >::shutdown().

template<typename Protocol>

logger services::stream_socket_service< Protocol >::logger_ `[private]`

The logger used for writing debug messages.

Definition at line 309 of file stream_socket_service.hpp.

Referenced by services::stream_socket_service< Protocol >::async_connect(), services::stream_socket_service< Protocol >::async_receive(), services::stream_socket_service< Protocol >::async_send(), services::stream_socket_service< Protocol >::bind(), services::stream_socket_service< Protocol >::close(), services::stream_socket_service< Protocol >::connect(), services::stream_socket_service< Protocol >::get_option(), services::stream_socket_service< Protocol >::io_control(), services::stream_socket_service< Protocol >::local_endpoint(), services::stream_socket_service< Protocol >::open(), services::stream_socket_service< Protocol >::receive(), services::stream_socket_service< Protocol >::remote_endpoint(), services::stream_socket_service< Protocol >::send(), services::stream_socket_service< Protocol >::set_option(), and services::stream_socket_service< Protocol >::shutdown().

The documentation for this class was generated from the following file:

- services/stream_socket_service.hpp

| Copyright © 2003 - 2006 Christopher M. Kohlhoff