Provides stream-oriented socket functionality. More...
#include <basic_stream_socket.hpp>
Public Types | |
typedef Protocol::endpoint | endpoint_type |
The endpoint type. | |
typedef StreamSocketService::native_type | native_type |
The native representation of a socket. | |
typedef Protocol | protocol_type |
The protocol type. | |
Public Member Functions | |
template<typename MutableBufferSequence , typename ReadHandler > | |
void | async_read_some (const MutableBufferSequence &buffers, ReadHandler handler) |
Start an asynchronous read. | |
template<typename MutableBufferSequence , typename ReadHandler > | |
void | async_receive (const MutableBufferSequence &buffers, ReadHandler handler) |
Start an asynchronous receive. | |
template<typename MutableBufferSequence , typename ReadHandler > | |
void | async_receive (const MutableBufferSequence &buffers, socket_base::message_flags flags, ReadHandler handler) |
Start an asynchronous receive. | |
template<typename ConstBufferSequence , typename WriteHandler > | |
void | async_send (const ConstBufferSequence &buffers, WriteHandler handler) |
Start an asynchronous send. | |
template<typename ConstBufferSequence , typename WriteHandler > | |
void | async_send (const ConstBufferSequence &buffers, socket_base::message_flags flags, WriteHandler handler) |
Start an asynchronous send. | |
template<typename ConstBufferSequence , typename WriteHandler > | |
void | async_write_some (const ConstBufferSequence &buffers, WriteHandler handler) |
Start an asynchronous write. | |
basic_stream_socket (asio::io_service &io_service) | |
Construct a basic_stream_socket without opening it. | |
basic_stream_socket (asio::io_service &io_service, const protocol_type &protocol) | |
Construct and open a basic_stream_socket. | |
basic_stream_socket (asio::io_service &io_service, const endpoint_type &endpoint) | |
basic_stream_socket (asio::io_service &io_service, const protocol_type &protocol, const native_type &native_socket) | |
Construct a basic_stream_socket on an existing native socket. | |
template<typename MutableBufferSequence > | |
std::size_t | read_some (const MutableBufferSequence &buffers) |
Read some data from the socket. | |
template<typename MutableBufferSequence > | |
std::size_t | read_some (const MutableBufferSequence &buffers, asio::error_code &ec) |
Read some data from the socket. | |
template<typename MutableBufferSequence > | |
std::size_t | receive (const MutableBufferSequence &buffers) |
Receive some data on the socket. | |
template<typename MutableBufferSequence > | |
std::size_t | receive (const MutableBufferSequence &buffers, socket_base::message_flags flags) |
Receive some data on the socket. | |
template<typename MutableBufferSequence > | |
std::size_t | receive (const MutableBufferSequence &buffers, socket_base::message_flags flags, asio::error_code &ec) |
Receive some data on a connected socket. | |
template<typename ConstBufferSequence > | |
std::size_t | send (const ConstBufferSequence &buffers) |
Send some data on the socket. | |
template<typename ConstBufferSequence > | |
std::size_t | send (const ConstBufferSequence &buffers, socket_base::message_flags flags) |
Send some data on the socket. | |
template<typename ConstBufferSequence > | |
std::size_t | send (const ConstBufferSequence &buffers, socket_base::message_flags flags, asio::error_code &ec) |
Send some data on the socket. | |
template<typename ConstBufferSequence > | |
std::size_t | write_some (const ConstBufferSequence &buffers) |
Write some data to the socket. | |
template<typename ConstBufferSequence > | |
std::size_t | write_some (const ConstBufferSequence &buffers, asio::error_code &ec) |
Write some data to the socket. |
Provides stream-oriented socket functionality.
The basic_stream_socket class template provides asynchronous and blocking stream-oriented socket functionality.
Definition at line 46 of file basic_stream_socket.hpp.
typedef Protocol::endpoint asio::basic_stream_socket< Protocol, StreamSocketService >::endpoint_type |
The endpoint type.
Reimplemented from asio::basic_socket< Protocol, StreamSocketService >.
Definition at line 57 of file basic_stream_socket.hpp.
typedef StreamSocketService::native_type asio::basic_stream_socket< Protocol, StreamSocketService >::native_type |
The native representation of a socket.
Reimplemented from asio::basic_socket< Protocol, StreamSocketService >.
Definition at line 51 of file basic_stream_socket.hpp.
typedef Protocol asio::basic_stream_socket< Protocol, StreamSocketService >::protocol_type |
The protocol type.
Reimplemented from asio::basic_socket< Protocol, StreamSocketService >.
Definition at line 54 of file basic_stream_socket.hpp.
asio::basic_stream_socket< Protocol, StreamSocketService >::basic_stream_socket | ( | asio::io_service & | io_service | ) | [inline, explicit] |
Construct a basic_stream_socket without opening it.
This constructor creates a stream socket without opening it. The socket needs to be opened and then connected or accepted before data can be sent or received on it.
io_service | The io_service object that the stream socket will use to dispatch handlers for any asynchronous operations performed on the socket. |
Definition at line 68 of file basic_stream_socket.hpp.
asio::basic_stream_socket< Protocol, StreamSocketService >::basic_stream_socket | ( | asio::io_service & | io_service, |
const protocol_type & | protocol | ||
) | [inline] |
Construct and open a basic_stream_socket.
This constructor creates and opens a stream socket. The socket needs to be connected or accepted before data can be sent or received on it.
io_service | The io_service object that the stream socket will use to dispatch handlers for any asynchronous operations performed on the socket. |
protocol | An object specifying protocol parameters to be used. |
asio::system_error | Thrown on failure. |
Definition at line 85 of file basic_stream_socket.hpp.
asio::basic_stream_socket< Protocol, StreamSocketService >::basic_stream_socket | ( | asio::io_service & | io_service, |
const endpoint_type & | endpoint | ||
) | [inline] |
Construct a basic_stream_socket, opening it and binding it to the given local endpoint. This constructor creates a stream socket and automatically opens it bound to the specified endpoint on the local machine. The protocol used is the protocol associated with the given endpoint.
io_service | The io_service object that the stream socket will use to dispatch handlers for any asynchronous operations performed on the socket. |
endpoint | An endpoint on the local machine to which the stream socket will be bound. |
asio::system_error | Thrown on failure. |
Definition at line 106 of file basic_stream_socket.hpp.
asio::basic_stream_socket< Protocol, StreamSocketService >::basic_stream_socket | ( | asio::io_service & | io_service, |
const protocol_type & | protocol, | ||
const native_type & | native_socket | ||
) | [inline] |
Construct a basic_stream_socket on an existing native socket.
This constructor creates a stream socket object to hold an existing native socket.
io_service | The io_service object that the stream socket will use to dispatch handlers for any asynchronous operations performed on the socket. |
protocol | An object specifying protocol parameters to be used. |
native_socket | The new underlying socket implementation. |
asio::system_error | Thrown on failure. |
Definition at line 126 of file basic_stream_socket.hpp.
void asio::basic_stream_socket< Protocol, StreamSocketService >::async_read_some | ( | const MutableBufferSequence & | buffers, |
ReadHandler | handler | ||
) | [inline] |
Start an asynchronous read.
This function is used to asynchronously read data from the stream socket. The function call always returns immediately.
buffers | One or more buffers into which the data will be read. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called. |
handler | The handler to be called when the read operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( const asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes read. ); |
socket.async_read_some(asio::buffer(data, size), handler);
Definition at line 707 of file basic_stream_socket.hpp.
void asio::basic_stream_socket< Protocol, StreamSocketService >::async_receive | ( | const MutableBufferSequence & | buffers, |
ReadHandler | handler | ||
) | [inline] |
Start an asynchronous receive.
This function is used to asynchronously receive data from the stream socket. The function call always returns immediately.
buffers | One or more buffers into which the data will be received. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called. |
handler | The handler to be called when the receive operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( const asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes received. ); |
socket.async_receive(asio::buffer(data, size), handler);
Definition at line 457 of file basic_stream_socket.hpp.
void asio::basic_stream_socket< Protocol, StreamSocketService >::async_receive | ( | const MutableBufferSequence & | buffers, |
socket_base::message_flags | flags, | ||
ReadHandler | handler | ||
) | [inline] |
Start an asynchronous receive.
This function is used to asynchronously receive data from the stream socket. The function call always returns immediately.
buffers | One or more buffers into which the data will be received. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called. |
flags | Flags specifying how the receive call is to be made. |
handler | The handler to be called when the receive operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( const asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes received. ); |
socket.async_receive(asio::buffer(data, size), 0, handler);
Definition at line 502 of file basic_stream_socket.hpp.
void asio::basic_stream_socket< Protocol, StreamSocketService >::async_send | ( | const ConstBufferSequence & | buffers, |
WriteHandler | handler | ||
) | [inline] |
Start an asynchronous send.
This function is used to asynchronously send data on the stream socket. The function call always returns immediately.
buffers | One or more data buffers to be sent on the socket. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called. |
handler | The handler to be called when the send operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( const asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes sent. ); |
socket.async_send(asio::buffer(data, size), handler);
Definition at line 267 of file basic_stream_socket.hpp.
void asio::basic_stream_socket< Protocol, StreamSocketService >::async_send | ( | const ConstBufferSequence & | buffers, |
socket_base::message_flags | flags, | ||
WriteHandler | handler | ||
) | [inline] |
Start an asynchronous send.
This function is used to asynchronously send data on the stream socket. The function call always returns immediately.
buffers | One or more data buffers to be sent on the socket. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called. |
flags | Flags specifying how the send call is to be made. |
handler | The handler to be called when the send operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( const asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes sent. ); |
socket.async_send(asio::buffer(data, size), 0, handler);
Definition at line 310 of file basic_stream_socket.hpp.
void asio::basic_stream_socket< Protocol, StreamSocketService >::async_write_some | ( | const ConstBufferSequence & | buffers, |
WriteHandler | handler | ||
) | [inline] |
Start an asynchronous write.
This function is used to asynchronously write data to the stream socket. The function call always returns immediately.
buffers | One or more data buffers to be written to the socket. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called. |
handler | The handler to be called when the write operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( const asio::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes written. ); |
socket.async_write_some(asio::buffer(data, size), handler);
Definition at line 603 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::read_some | ( | const MutableBufferSequence & | buffers | ) | [inline] |
Read some data from the socket.
This function is used to read data from the stream socket. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
buffers | One or more buffers into which the data will be read. |
asio::system_error | Thrown on failure. An error code of asio::error::eof indicates that the connection was closed by the peer. |
socket.read_some(asio::buffer(data, size));
Definition at line 638 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::read_some | ( | const MutableBufferSequence & | buffers, |
asio::error_code & | ec | ||
) | [inline] |
Read some data from the socket.
This function is used to read data from the stream socket. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
buffers | One or more buffers into which the data will be read. |
ec | Set to indicate what error occurred, if any. |
Definition at line 664 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::receive | ( | const MutableBufferSequence & | buffers | ) | [inline] |
Receive some data on the socket.
This function is used to receive data on the stream socket. The function call will block until one or more bytes of data has been received successfully, or until an error occurs.
buffers | One or more buffers into which the data will be received. |
asio::system_error | Thrown on failure. An error code of asio::error::eof indicates that the connection was closed by the peer. |
socket.receive(asio::buffer(data, size));
Definition at line 345 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::receive | ( | const MutableBufferSequence & | buffers, |
socket_base::message_flags | flags | ||
) | [inline] |
Receive some data on the socket.
This function is used to receive data on the stream socket. The function call will block until one or more bytes of data has been received successfully, or until an error occurs.
buffers | One or more buffers into which the data will be received. |
flags | Flags specifying how the receive call is to be made. |
asio::system_error | Thrown on failure. An error code of asio::error::eof indicates that the connection was closed by the peer. |
socket.receive(asio::buffer(data, size), 0);
Definition at line 384 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::receive | ( | const MutableBufferSequence & | buffers, |
socket_base::message_flags | flags, | ||
asio::error_code & | ec | ||
) | [inline] |
Receive some data on a connected socket.
This function is used to receive data on the stream socket. The function call will block until one or more bytes of data has been received successfully, or until an error occurs.
buffers | One or more buffers into which the data will be received. |
flags | Flags specifying how the receive call is to be made. |
ec | Set to indicate what error occurred, if any. |
Definition at line 413 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::send | ( | const ConstBufferSequence & | buffers | ) | [inline] |
Send some data on the socket.
This function is used to send data on the stream socket. The function call will block until one or more bytes of the data has been sent successfully, or an until error occurs.
buffers | One or more data buffers to be sent on the socket. |
asio::system_error | Thrown on failure. |
socket.send(asio::buffer(data, size));
Definition at line 159 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::send | ( | const ConstBufferSequence & | buffers, |
socket_base::message_flags | flags | ||
) | [inline] |
Send some data on the socket.
This function is used to send data on the stream socket. The function call will block until one or more bytes of the data has been sent successfully, or an until error occurs.
buffers | One or more data buffers to be sent on the socket. |
flags | Flags specifying how the send call is to be made. |
asio::system_error | Thrown on failure. |
socket.send(asio::buffer(data, size), 0);
Definition at line 196 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::send | ( | const ConstBufferSequence & | buffers, |
socket_base::message_flags | flags, | ||
asio::error_code & | ec | ||
) | [inline] |
Send some data on the socket.
This function is used to send data on the stream socket. The function call will block until one or more bytes of the data has been sent successfully, or an until error occurs.
buffers | One or more data buffers to be sent on the socket. |
flags | Flags specifying how the send call is to be made. |
ec | Set to indicate what error occurred, if any. |
Definition at line 225 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::write_some | ( | const ConstBufferSequence & | buffers | ) | [inline] |
Write some data to the socket.
This function is used to write data to the stream socket. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
buffers | One or more data buffers to be written to the socket. |
asio::system_error | Thrown on failure. An error code of asio::error::eof indicates that the connection was closed by the peer. |
socket.write_some(asio::buffer(data, size));
Definition at line 536 of file basic_stream_socket.hpp.
std::size_t asio::basic_stream_socket< Protocol, StreamSocketService >::write_some | ( | const ConstBufferSequence & | buffers, |
asio::error_code & | ec | ||
) | [inline] |
Write some data to the socket.
This function is used to write data to the stream socket. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
buffers | One or more data buffers to be written to the socket. |
ec | Set to indicate what error occurred, if any. |
Definition at line 561 of file basic_stream_socket.hpp.