Examples |
Definition at line 23 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 (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. | |
asio::error_code | open (implementation_type &impl, const protocol_type &protocol, asio::error_code &ec) |
Open a new stream socket implementation. | |
asio::error_code | assign (implementation_type &impl, const protocol_type &protocol, const native_type &native_socket, asio::error_code &ec) |
Open a stream socket from an existing native socket. | |
bool | is_open (const implementation_type &impl) const |
Determine whether the socket is open. | |
asio::error_code | close (implementation_type &impl, asio::error_code &ec) |
Close a stream socket implementation. | |
bool | at_mark (const implementation_type &impl, asio::error_code &ec) const |
Determine whether the socket is at the out-of-band data mark. | |
std::size_t | available (const implementation_type &impl, asio::error_code &ec) const |
Determine the number of bytes available for reading. | |
asio::error_code | bind (implementation_type &impl, const endpoint_type &endpoint, asio::error_code &ec) |
Bind the stream socket to the specified local endpoint. | |
asio::error_code | connect (implementation_type &impl, const endpoint_type &peer_endpoint, asio::error_code &ec) |
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> | |
asio::error_code | set_option (implementation_type &impl, const Option &option, asio::error_code &ec) |
Set a socket option. | |
template<typename Option> | |
asio::error_code | get_option (const implementation_type &impl, Option &option, asio::error_code &ec) const |
Get a socket option. | |
template<typename IO_Control_Command> | |
asio::error_code | io_control (implementation_type &impl, IO_Control_Command &command, asio::error_code &ec) |
Perform an IO control command on the socket. | |
endpoint_type | local_endpoint (const implementation_type &impl, asio::error_code &ec) const |
Get the local endpoint. | |
endpoint_type | remote_endpoint (const implementation_type &impl, asio::error_code &ec) const |
Get the remote endpoint. | |
asio::error_code | shutdown (implementation_type &impl, asio::socket_base::shutdown_type what, asio::error_code &ec) |
Disable sends or receives on the socket. | |
template<typename Const_Buffers> | |
std::size_t | send (implementation_type &impl, const Const_Buffers &buffers, asio::socket_base::message_flags flags, asio::error_code &ec) |
Send the given data to the peer. | |
template<typename Const_Buffers, typename Handler> | |
void | async_send (implementation_type &impl, const Const_Buffers &buffers, asio::socket_base::message_flags flags, Handler handler) |
Start an asynchronous send. | |
template<typename Mutable_Buffers> | |
std::size_t | receive (implementation_type &impl, const Mutable_Buffers &buffers, asio::socket_base::message_flags flags, asio::error_code &ec) |
Receive some data from the peer. | |
template<typename Mutable_Buffers, typename Handler> | |
void | async_receive (implementation_type &impl, const Mutable_Buffers &buffers, asio::socket_base::message_flags flags, Handler handler) |
Start an asynchronous receive. | |
Static Public Attributes | |
static asio::io_service::id | id |
The unique service identifier. | |
Private Types | |
typedef 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... |
typedef 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 28 of file stream_socket_service.hpp.
typedef Protocol services::stream_socket_service< Protocol >::protocol_type |
typedef Protocol::endpoint services::stream_socket_service< Protocol >::endpoint_type |
typedef service_impl_type::implementation_type services::stream_socket_service< Protocol >::implementation_type |
The implementation type of a stream socket.
Definition at line 41 of file stream_socket_service.hpp.
typedef service_impl_type::native_type services::stream_socket_service< Protocol >::native_type |
services::stream_socket_service< Protocol >::stream_socket_service | ( | asio::io_service & | io_service | ) | [explicit] |
Construct a new stream socket service for the specified io_service.
Definition at line 47 of file stream_socket_service.hpp.
00048 : asio::io_service::service(io_service), 00049 service_impl_(asio::use_service<service_impl_type>(io_service)), 00050 logger_(io_service, "stream_socket") 00051 { 00052 }
void services::stream_socket_service< Protocol >::shutdown_service | ( | ) | [virtual] |
Destroy all user-defined handler objects owned by the service.
Implements asio::io_service::service.
Definition at line 55 of file stream_socket_service.hpp.
void services::stream_socket_service< Protocol >::construct | ( | implementation_type & | impl | ) |
Construct a new stream socket implementation.
Definition at line 60 of file stream_socket_service.hpp.
00061 { 00062 service_impl_.construct(impl); 00063 }
void services::stream_socket_service< Protocol >::destroy | ( | implementation_type & | impl | ) |
Destroy a stream socket implementation.
Definition at line 66 of file stream_socket_service.hpp.
00067 { 00068 service_impl_.destroy(impl); 00069 }
asio::error_code services::stream_socket_service< Protocol >::open | ( | implementation_type & | impl, | |
const protocol_type & | protocol, | |||
asio::error_code & | ec | |||
) |
Open a new stream socket implementation.
Definition at line 72 of file stream_socket_service.hpp.
00074 { 00075 logger_.log("Opening new socket"); 00076 return service_impl_.open(impl, protocol, ec); 00077 }
asio::error_code services::stream_socket_service< Protocol >::assign | ( | implementation_type & | impl, | |
const protocol_type & | protocol, | |||
const native_type & | native_socket, | |||
asio::error_code & | ec | |||
) |
Open a stream socket from an existing native socket.
Definition at line 80 of file stream_socket_service.hpp.
00083 { 00084 logger_.log("Assigning from a native socket"); 00085 return service_impl_.assign(impl, protocol, native_socket, ec); 00086 }
bool services::stream_socket_service< Protocol >::is_open | ( | const implementation_type & | impl | ) | const |
Determine whether the socket is open.
Definition at line 89 of file stream_socket_service.hpp.
00090 { 00091 logger_.log("Checking if socket is open"); 00092 return service_impl_.is_open(impl); 00093 }
asio::error_code services::stream_socket_service< Protocol >::close | ( | implementation_type & | impl, | |
asio::error_code & | ec | |||
) |
Close a stream socket implementation.
Definition at line 96 of file stream_socket_service.hpp.
00098 { 00099 logger_.log("Closing socket"); 00100 return service_impl_.close(impl, ec); 00101 }
bool services::stream_socket_service< Protocol >::at_mark | ( | const implementation_type & | impl, | |
asio::error_code & | ec | |||
) | const |
Determine whether the socket is at the out-of-band data mark.
Definition at line 104 of file stream_socket_service.hpp.
00106 { 00107 logger_.log("Checking if socket is at out-of-band data mark"); 00108 return service_impl_.at_mark(impl, ec); 00109 }
std::size_t services::stream_socket_service< Protocol >::available | ( | const implementation_type & | impl, | |
asio::error_code & | ec | |||
) | const |
Determine the number of bytes available for reading.
Definition at line 112 of file stream_socket_service.hpp.
00114 { 00115 logger_.log("Determining number of bytes available for reading"); 00116 return service_impl_.available(impl, ec); 00117 }
asio::error_code services::stream_socket_service< Protocol >::bind | ( | implementation_type & | impl, | |
const endpoint_type & | endpoint, | |||
asio::error_code & | ec | |||
) |
Bind the stream socket to the specified local endpoint.
Definition at line 120 of file stream_socket_service.hpp.
00122 { 00123 logger_.log("Binding socket"); 00124 return service_impl_.bind(impl, endpoint, ec); 00125 }
asio::error_code services::stream_socket_service< Protocol >::connect | ( | implementation_type & | impl, | |
const endpoint_type & | peer_endpoint, | |||
asio::error_code & | ec | |||
) |
Connect the stream socket to the specified endpoint.
Definition at line 128 of file stream_socket_service.hpp.
00130 { 00131 logger_.log("Connecting socket to " + 00132 boost::lexical_cast<std::string>(peer_endpoint)); 00133 return service_impl_.connect(impl, peer_endpoint, ec); 00134 }
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 170 of file stream_socket_service.hpp.
00172 { 00173 logger_.log("Starting asynchronous connect to " + 00174 boost::lexical_cast<std::string>(peer_endpoint)); 00175 service_impl_.async_connect(impl, peer_endpoint, 00176 connect_handler<Handler>(handler, logger_)); 00177 }
asio::error_code services::stream_socket_service< Protocol >::set_option | ( | implementation_type & | impl, | |
const Option & | option, | |||
asio::error_code & | ec | |||
) |
Set a socket option.
Definition at line 181 of file stream_socket_service.hpp.
00183 { 00184 logger_.log("Setting socket option"); 00185 return service_impl_.set_option(impl, option, ec); 00186 }
asio::error_code services::stream_socket_service< Protocol >::get_option | ( | const implementation_type & | impl, | |
Option & | option, | |||
asio::error_code & | ec | |||
) | const |
Get a socket option.
Definition at line 190 of file stream_socket_service.hpp.
00192 { 00193 logger_.log("Getting socket option"); 00194 return service_impl_.get_option(impl, option, ec); 00195 }
asio::error_code services::stream_socket_service< Protocol >::io_control | ( | implementation_type & | impl, | |
IO_Control_Command & | command, | |||
asio::error_code & | ec | |||
) |
Perform an IO control command on the socket.
Definition at line 199 of file stream_socket_service.hpp.
00201 { 00202 logger_.log("Performing IO control command on socket"); 00203 return service_impl_.io_control(impl, command, ec); 00204 }
endpoint_type services::stream_socket_service< Protocol >::local_endpoint | ( | const implementation_type & | impl, | |
asio::error_code & | ec | |||
) | const |
Get the local endpoint.
Definition at line 207 of file stream_socket_service.hpp.
00209 { 00210 logger_.log("Getting socket's local endpoint"); 00211 return service_impl_.local_endpoint(impl, ec); 00212 }
endpoint_type services::stream_socket_service< Protocol >::remote_endpoint | ( | const implementation_type & | impl, | |
asio::error_code & | ec | |||
) | const |
Get the remote endpoint.
Definition at line 215 of file stream_socket_service.hpp.
00217 { 00218 logger_.log("Getting socket's remote endpoint"); 00219 return service_impl_.remote_endpoint(impl, ec); 00220 }
asio::error_code services::stream_socket_service< Protocol >::shutdown | ( | implementation_type & | impl, | |
asio::socket_base::shutdown_type | what, | |||
asio::error_code & | ec | |||
) |
Disable sends or receives on the socket.
Definition at line 223 of file stream_socket_service.hpp.
00226 { 00227 logger_.log("Shutting down socket"); 00228 return service_impl_.shutdown(impl, what, ec); 00229 }
std::size_t services::stream_socket_service< Protocol >::send | ( | implementation_type & | impl, | |
const Const_Buffers & | buffers, | |||
asio::socket_base::message_flags | flags, | |||
asio::error_code & | ec | |||
) |
Send the given data to the peer.
Definition at line 233 of file stream_socket_service.hpp.
00236 { 00237 logger_.log("Sending data on socket"); 00238 return service_impl_.send(impl, buffers, flags, ec); 00239 }
void services::stream_socket_service< Protocol >::async_send | ( | implementation_type & | impl, | |
const Const_Buffers & | buffers, | |||
asio::socket_base::message_flags | flags, | |||
Handler | handler | |||
) |
Start an asynchronous send.
Definition at line 276 of file stream_socket_service.hpp.
00278 { 00279 logger_.log("Starting asynchronous send"); 00280 service_impl_.async_send(impl, buffers, flags, 00281 send_handler<Handler>(handler, logger_)); 00282 }
std::size_t services::stream_socket_service< Protocol >::receive | ( | implementation_type & | impl, | |
const Mutable_Buffers & | buffers, | |||
asio::socket_base::message_flags | flags, | |||
asio::error_code & | ec | |||
) |
Receive some data from the peer.
Definition at line 286 of file stream_socket_service.hpp.
00290 { 00291 logger_.log("Receiving data on socket"); 00292 return service_impl_.receive(impl, buffers, flags, ec); 00293 }
void services::stream_socket_service< Protocol >::async_receive | ( | implementation_type & | impl, | |
const Mutable_Buffers & | buffers, | |||
asio::socket_base::message_flags | flags, | |||
Handler | handler | |||
) |
Start an asynchronous receive.
Definition at line 330 of file stream_socket_service.hpp.
00332 { 00333 logger_.log("Starting asynchronous receive"); 00334 service_impl_.async_receive(impl, buffers, flags, 00335 receive_handler<Handler>(handler, logger_)); 00336 }
asio::io_service::id services::stream_socket_service< Protocol >::id [static] |
service_impl_type& services::stream_socket_service< Protocol >::service_impl_ [private] |
The wrapped stream socket service.
Definition at line 340 of file stream_socket_service.hpp.
Referenced by services::stream_socket_service< Protocol >::assign(), 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 >::at_mark(), services::stream_socket_service< Protocol >::available(), 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 >::is_open(), 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().
logger services::stream_socket_service< Protocol >::logger_ [mutable, private] |
The logger used for writing debug messages.
Definition at line 343 of file stream_socket_service.hpp.
Referenced by services::stream_socket_service< Protocol >::assign(), 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 >::at_mark(), services::stream_socket_service< Protocol >::available(), 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 >::is_open(), 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().