Provides raw-oriented socket functionality. More...
#include <basic_raw_socket.hpp>
Public Types | |
typedef Protocol::endpoint | endpoint_type |
The endpoint type. | |
typedef RawSocketService::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_receive (const MutableBufferSequence &buffers, ReadHandler handler) |
Start an asynchronous receive on a connected socket. | |
template<typename MutableBufferSequence , typename ReadHandler > | |
void | async_receive (const MutableBufferSequence &buffers, socket_base::message_flags flags, ReadHandler handler) |
Start an asynchronous receive on a connected socket. | |
template<typename MutableBufferSequence , typename ReadHandler > | |
void | async_receive_from (const MutableBufferSequence &buffers, endpoint_type &sender_endpoint, ReadHandler handler) |
Start an asynchronous receive. | |
template<typename MutableBufferSequence , typename ReadHandler > | |
void | async_receive_from (const MutableBufferSequence &buffers, endpoint_type &sender_endpoint, 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 on a connected socket. | |
template<typename ConstBufferSequence , typename WriteHandler > | |
void | async_send (const ConstBufferSequence &buffers, socket_base::message_flags flags, WriteHandler handler) |
Start an asynchronous send on a connected socket. | |
template<typename ConstBufferSequence , typename WriteHandler > | |
void | async_send_to (const ConstBufferSequence &buffers, const endpoint_type &destination, WriteHandler handler) |
Start an asynchronous send. | |
template<typename ConstBufferSequence , typename WriteHandler > | |
void | async_send_to (const ConstBufferSequence &buffers, const endpoint_type &destination, socket_base::message_flags flags, WriteHandler handler) |
Start an asynchronous send. | |
basic_raw_socket (asio::io_service &io_service) | |
Construct a basic_raw_socket without opening it. | |
basic_raw_socket (asio::io_service &io_service, const protocol_type &protocol) | |
Construct and open a basic_raw_socket. | |
basic_raw_socket (asio::io_service &io_service, const endpoint_type &endpoint) | |
basic_raw_socket (asio::io_service &io_service, const protocol_type &protocol, const native_type &native_socket) | |
Construct a basic_raw_socket on an existing native socket. | |
template<typename MutableBufferSequence > | |
std::size_t | receive (const MutableBufferSequence &buffers) |
Receive some data on a connected socket. | |
template<typename MutableBufferSequence > | |
std::size_t | receive (const MutableBufferSequence &buffers, socket_base::message_flags flags) |
Receive some data on a connected 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 MutableBufferSequence > | |
std::size_t | receive_from (const MutableBufferSequence &buffers, endpoint_type &sender_endpoint) |
Receive raw data with the endpoint of the sender. | |
template<typename MutableBufferSequence > | |
std::size_t | receive_from (const MutableBufferSequence &buffers, endpoint_type &sender_endpoint, socket_base::message_flags flags) |
Receive raw data with the endpoint of the sender. | |
template<typename MutableBufferSequence > | |
std::size_t | receive_from (const MutableBufferSequence &buffers, endpoint_type &sender_endpoint, socket_base::message_flags flags, asio::error_code &ec) |
Receive raw data with the endpoint of the sender. | |
template<typename ConstBufferSequence > | |
std::size_t | send (const ConstBufferSequence &buffers) |
Send some data on a connected socket. | |
template<typename ConstBufferSequence > | |
std::size_t | send (const ConstBufferSequence &buffers, socket_base::message_flags flags) |
Send some data on a connected socket. | |
template<typename ConstBufferSequence > | |
std::size_t | send (const ConstBufferSequence &buffers, socket_base::message_flags flags, asio::error_code &ec) |
Send some data on a connected socket. | |
template<typename ConstBufferSequence > | |
std::size_t | send_to (const ConstBufferSequence &buffers, const endpoint_type &destination) |
Send raw data to the specified endpoint. | |
template<typename ConstBufferSequence > | |
std::size_t | send_to (const ConstBufferSequence &buffers, const endpoint_type &destination, socket_base::message_flags flags) |
Send raw data to the specified endpoint. | |
template<typename ConstBufferSequence > | |
std::size_t | send_to (const ConstBufferSequence &buffers, const endpoint_type &destination, socket_base::message_flags flags, asio::error_code &ec) |
Send raw data to the specified endpoint. |
Provides raw-oriented socket functionality.
The basic_raw_socket class template provides asynchronous and blocking raw-oriented socket functionality.
Definition at line 43 of file basic_raw_socket.hpp.
typedef Protocol::endpoint asio::basic_raw_socket< Protocol, RawSocketService >::endpoint_type |
The endpoint type.
Reimplemented from asio::basic_socket< Protocol, RawSocketService >.
Definition at line 54 of file basic_raw_socket.hpp.
typedef RawSocketService::native_type asio::basic_raw_socket< Protocol, RawSocketService >::native_type |
The native representation of a socket.
Reimplemented from asio::basic_socket< Protocol, RawSocketService >.
Definition at line 48 of file basic_raw_socket.hpp.
typedef Protocol asio::basic_raw_socket< Protocol, RawSocketService >::protocol_type |
The protocol type.
Reimplemented from asio::basic_socket< Protocol, RawSocketService >.
Definition at line 51 of file basic_raw_socket.hpp.
asio::basic_raw_socket< Protocol, RawSocketService >::basic_raw_socket | ( | asio::io_service & | io_service | ) | [inline, explicit] |
Construct a basic_raw_socket without opening it.
This constructor creates a raw socket without opening it. The open() function must be called before data can be sent or received on the socket.
io_service | The io_service object that the raw socket will use to dispatch handlers for any asynchronous operations performed on the socket. |
Definition at line 65 of file basic_raw_socket.hpp.
asio::basic_raw_socket< Protocol, RawSocketService >::basic_raw_socket | ( | asio::io_service & | io_service, |
const protocol_type & | protocol | ||
) | [inline] |
Construct and open a basic_raw_socket.
This constructor creates and opens a raw socket.
io_service | The io_service object that the raw 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 82 of file basic_raw_socket.hpp.
asio::basic_raw_socket< Protocol, RawSocketService >::basic_raw_socket | ( | asio::io_service & | io_service, |
const endpoint_type & | endpoint | ||
) | [inline] |
Construct a basic_raw_socket, opening it and binding it to the given local endpoint. This constructor creates a raw 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 raw socket will use to dispatch handlers for any asynchronous operations performed on the socket. |
endpoint | An endpoint on the local machine to which the raw socket will be bound. |
asio::system_error | Thrown on failure. |
Definition at line 104 of file basic_raw_socket.hpp.
asio::basic_raw_socket< Protocol, RawSocketService >::basic_raw_socket | ( | asio::io_service & | io_service, |
const protocol_type & | protocol, | ||
const native_type & | native_socket | ||
) | [inline] |
Construct a basic_raw_socket on an existing native socket.
This constructor creates a raw socket object to hold an existing native socket.
io_service | The io_service object that the raw 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 125 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_receive | ( | const MutableBufferSequence & | buffers, |
ReadHandler | handler | ||
) | [inline] |
Start an asynchronous receive on a connected socket.
This function is used to asynchronously receive data from the raw 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 582 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_receive | ( | const MutableBufferSequence & | buffers, |
socket_base::message_flags | flags, | ||
ReadHandler | handler | ||
) | [inline] |
Start an asynchronous receive on a connected socket.
This function is used to asynchronously receive data from the raw 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. ); |
Definition at line 616 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_receive_from | ( | const MutableBufferSequence & | buffers, |
endpoint_type & | sender_endpoint, | ||
ReadHandler | handler | ||
) | [inline] |
Start an asynchronous receive.
This function is used to asynchronously receive raw data. 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. |
sender_endpoint | An endpoint object that receives the endpoint of the remote sender of the data. Ownership of the sender_endpoint object is retained by the caller, which must guarantee that it is 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_from( asio::buffer(data, size), 0, sender_endpoint, handler);
Definition at line 748 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_receive_from | ( | const MutableBufferSequence & | buffers, |
endpoint_type & | sender_endpoint, | ||
socket_base::message_flags | flags, | ||
ReadHandler | handler | ||
) | [inline] |
Start an asynchronous receive.
This function is used to asynchronously receive raw data. 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. |
sender_endpoint | An endpoint object that receives the endpoint of the remote sender of the data. Ownership of the sender_endpoint object is retained by the caller, which must guarantee that it is 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. ); |
Definition at line 785 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_send | ( | const ConstBufferSequence & | buffers, |
WriteHandler | handler | ||
) | [inline] |
Start an asynchronous send on a connected socket.
This function is used to send data on the raw socket. The function call will block until the data has been sent successfully or an error occurs.
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 248 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_send | ( | const ConstBufferSequence & | buffers, |
socket_base::message_flags | flags, | ||
WriteHandler | handler | ||
) | [inline] |
Start an asynchronous send on a connected socket.
This function is used to send data on the raw socket. The function call will block until the data has been sent successfully or an error occurs.
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. ); |
Definition at line 282 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_send_to | ( | const ConstBufferSequence & | buffers, |
const endpoint_type & | destination, | ||
WriteHandler | handler | ||
) | [inline] |
Start an asynchronous send.
This function is used to asynchronously send raw data to the specified remote endpoint. The function call always returns immediately.
buffers | One or more data buffers to be sent to the remote endpoint. 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. |
destination | The remote endpoint to which the data will be sent. Copies will be made of the endpoint as required. |
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. ); |
asio::ip::udp::endpoint destination( asio::ip::address::from_string("1.2.3.4"), 12345); socket.async_send_to( asio::buffer(data, size), destination, handler);
Definition at line 414 of file basic_raw_socket.hpp.
void asio::basic_raw_socket< Protocol, RawSocketService >::async_send_to | ( | const ConstBufferSequence & | buffers, |
const endpoint_type & | destination, | ||
socket_base::message_flags | flags, | ||
WriteHandler | handler | ||
) | [inline] |
Start an asynchronous send.
This function is used to asynchronously send raw data to the specified remote endpoint. The function call always returns immediately.
buffers | One or more data buffers to be sent to the remote endpoint. 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. |
destination | The remote endpoint to which the data will be sent. Copies will be made of the endpoint as required. |
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. ); |
Definition at line 449 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::receive | ( | const MutableBufferSequence & | buffers | ) | [inline] |
Receive some data on a connected socket.
This function is used to receive data on the raw socket. The function call will block until data has been received successfully or an error occurs.
buffers | One or more buffers into which the data will be received. |
asio::system_error | Thrown on failure. |
socket.receive(asio::buffer(data, size));
Definition at line 482 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::receive | ( | const MutableBufferSequence & | buffers, |
socket_base::message_flags | flags | ||
) | [inline] |
Receive some data on a connected socket.
This function is used to receive data on the raw socket. The function call will block until data has been received successfully or 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. |
Definition at line 510 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::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 raw socket. The function call will block until data has been received successfully or 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 539 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::receive_from | ( | const MutableBufferSequence & | buffers, |
endpoint_type & | sender_endpoint | ||
) | [inline] |
Receive raw data with the endpoint of the sender.
This function is used to receive raw data. The function call will block until data has been received successfully or an error occurs.
buffers | One or more buffers into which the data will be received. |
sender_endpoint | An endpoint object that receives the endpoint of the remote sender of the data. |
asio::system_error | Thrown on failure. |
asio::ip::udp::endpoint sender_endpoint; socket.receive_from( asio::buffer(data, size), sender_endpoint);
Definition at line 649 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::receive_from | ( | const MutableBufferSequence & | buffers, |
endpoint_type & | sender_endpoint, | ||
socket_base::message_flags | flags | ||
) | [inline] |
Receive raw data with the endpoint of the sender.
This function is used to receive raw data. The function call will block until data has been received successfully or an error occurs.
buffers | One or more buffers into which the data will be received. |
sender_endpoint | An endpoint object that receives the endpoint of the remote sender of the data. |
flags | Flags specifying how the receive call is to be made. |
asio::system_error | Thrown on failure. |
Definition at line 676 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::receive_from | ( | const MutableBufferSequence & | buffers, |
endpoint_type & | sender_endpoint, | ||
socket_base::message_flags | flags, | ||
asio::error_code & | ec | ||
) | [inline] |
Receive raw data with the endpoint of the sender.
This function is used to receive raw data. The function call will block until data has been received successfully or an error occurs.
buffers | One or more buffers into which the data will be received. |
sender_endpoint | An endpoint object that receives the endpoint of the remote sender of the data. |
flags | Flags specifying how the receive call is to be made. |
ec | Set to indicate what error occurred, if any. |
Definition at line 703 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::send | ( | const ConstBufferSequence & | buffers | ) | [inline] |
Send some data on a connected socket.
This function is used to send data on the raw socket. The function call will block until the data has been sent successfully or an error occurs.
buffers | One ore more data buffers to be sent on the socket. |
asio::system_error | Thrown on failure. |
socket.send(asio::buffer(data, size));
Definition at line 154 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::send | ( | const ConstBufferSequence & | buffers, |
socket_base::message_flags | flags | ||
) | [inline] |
Send some data on a connected socket.
This function is used to send data on the raw socket. The function call will block until the data has been sent successfully or an error occurs.
buffers | One ore 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. |
Definition at line 179 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::send | ( | const ConstBufferSequence & | buffers, |
socket_base::message_flags | flags, | ||
asio::error_code & | ec | ||
) | [inline] |
Send some data on a connected socket.
This function is used to send data on the raw socket. The function call will block until the data has been sent successfully or an 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 206 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::send_to | ( | const ConstBufferSequence & | buffers, |
const endpoint_type & | destination | ||
) | [inline] |
Send raw data to the specified endpoint.
This function is used to send raw data to the specified remote endpoint. The function call will block until the data has been sent successfully or an error occurs.
buffers | One or more data buffers to be sent to the remote endpoint. |
destination | The remote endpoint to which the data will be sent. |
asio::system_error | Thrown on failure. |
asio::ip::udp::endpoint destination( asio::ip::address::from_string("1.2.3.4"), 12345); socket.send_to(asio::buffer(data, size), destination);
Definition at line 314 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::send_to | ( | const ConstBufferSequence & | buffers, |
const endpoint_type & | destination, | ||
socket_base::message_flags | flags | ||
) | [inline] |
Send raw data to the specified endpoint.
This function is used to send raw data to the specified remote endpoint. The function call will block until the data has been sent successfully or an error occurs.
buffers | One or more data buffers to be sent to the remote endpoint. |
destination | The remote endpoint to which the data will be sent. |
flags | Flags specifying how the send call is to be made. |
asio::system_error | Thrown on failure. |
Definition at line 341 of file basic_raw_socket.hpp.
std::size_t asio::basic_raw_socket< Protocol, RawSocketService >::send_to | ( | const ConstBufferSequence & | buffers, |
const endpoint_type & | destination, | ||
socket_base::message_flags | flags, | ||
asio::error_code & | ec | ||
) | [inline] |
Send raw data to the specified endpoint.
This function is used to send raw data to the specified remote endpoint. The function call will block until the data has been sent successfully or an error occurs.
buffers | One or more data buffers to be sent to the remote endpoint. |
destination | The remote endpoint to which the data will be sent. |
flags | Flags specifying how the send call is to be made. |
ec | Set to indicate what error occurred, if any. |
Definition at line 368 of file basic_raw_socket.hpp.