Chops Net IP
|
The basic_io_output
class template provides methods for sending data to an associated network IO handler (TCP or UDP IO handler) or getting output queue statistics.
More...
#include <basic_io_output.hpp>
Public Types | |
using | endpoint_type = typename IOT::endpoint_type |
Public Member Functions | |
basic_io_output ()=default | |
Default construct a basic_io_output . | |
basic_io_output (std::weak_ptr< IOT > p) noexcept | |
Construct a std::weak_ptr to an internal IO handler. This constructor is for internal use only and not to be used by application code. | |
bool | is_valid () const noexcept |
Query whether an IO handler is associated with this object. | |
auto | get_output_queue_stats () const -> nonstd::expected< output_queue_stats, std::error_code > |
Return output queue statistics, allowing application monitoring of output queue sizes. | |
bool | send (const void *buf, std::size_t sz) const |
Send a buffer of data through the associated network IO handler. | |
bool | send (const chops::const_shared_buffer &buf) const |
Send a reference counted buffer through the associated network IO handler. | |
bool | send (chops::mutable_shared_buffer &&buf) const |
Move a reference counted buffer and send it through the associated network IO handler. | |
bool | send (const void *buf, std::size_t sz, const endpoint_type &endp) const |
Send a buffer to a specific destination endpoint (address and port), implemented only for UDP IO handlers. | |
bool | send (const chops::const_shared_buffer &buf, const endpoint_type &endp) const |
Send a reference counted buffer to a specific destination endpoint (address and port), implemented only for UDP IO handlers. | |
bool | send (chops::mutable_shared_buffer &&buf, const endpoint_type &endp) const |
Move a reference counted buffer and send it through the associated network IO handler, implemented only for UDP IO handlers. | |
bool | operator== (const basic_io_output< IOT > &rhs) const noexcept |
Compare two basic_io_output objects for equality. | |
bool | operator< (const basic_io_output< IOT > &rhs) const noexcept |
Compare two basic_io_output objects for ordering purposes. | |
Related Symbols | |
(Note that these are not member symbols.) | |
using | tcp_io = detail::tcp_io |
Using declaration for TCP based io, used to instantiate a basic_io_interface or basic_io_output type. | |
using | udp_io = detail::udp_entity_io |
Using declaration for UDP based io, used to instantiate a basic_io_interface or basic_io_output type. | |
using | tcp_io_output = basic_io_output<tcp_io> |
Using declaration for a TCP based basic_io_output type. | |
using | udp_io_output = basic_io_output<udp_io> |
Using declaration for a UDP based basic_io_output type. | |
The basic_io_output
class template provides methods for sending data to an associated network IO handler (TCP or UDP IO handler) or getting output queue statistics.
The basic_io_output
class provides the primary application interface for network IO data sending, whether TCP or UDP. This class provides methods to send data and query output queue stats.
Unless default constructed, a basic_io_output
object has an association to an IO handler object.
This class is a lightweight value class, allowing basic_io_output
objects to be copied and used in multiple places in an application, all of them accessing the same network IO handler.
All basic_io_output
send
methods can be called concurrently from multiple threads.
|
default |
Default construct a basic_io_output
.
A basic_io_output
is not useful until an active basic_io_output
is assigned into it.
|
inline |
Return output queue statistics, allowing application monitoring of output queue sizes.
nonstd::expected
- output_queue_stats
on success; on error (if no associated IO handler), a std::error_code
is returned.
|
inlinenoexcept |
Query whether an IO handler is associated with this object.
If true
, an IO handler (e.g. TCP or UDP IO handler) is associated. However, the IO handler may be closed or shutting down, which means it will not queue any sent data.
true
if associated with an IO handler.
|
inlinenoexcept |
Compare two basic_io_output
objects for ordering purposes.
The comparison is made through the std::shared_ptr
operator<
method. All invalid basic_io_output
objects are less than valid ones. When both are valid, the address ordering is returned.
|
inlinenoexcept |
Compare two basic_io_output
objects for equality.
The comparison is made through the std::shared_ptr
operator==
method. The comparison is made on addresses if both basic_io_output
objects are valid. If both basic_io_output
objects are invalid, true
is returned (this implies that all invalid basic_io_output
objects are equivalent). If one is valid and the other invalid, false
is returned.
|
inline |
Move a reference counted buffer and send it through the associated network IO handler.
To save a buffer copy, applications can create a chops::mutable_shared_buffer
, fill it with data, then move it into a chops::const_shared_buffer
. For example:
This is a non-blocking call.
buf | chops::mutable_shared_buffer containing data. |
true
if buffer written or queued for output, false
otherwise (no IO handler association, or IO handler stopped).
|
inline |
Move a reference counted buffer and send it through the associated network IO handler, implemented only for UDP IO handlers.
See documentation for send
without endpoint that moves a chops::mutable_shared_buffer
. This is a non-blocking call.
buf | chops::mutable_shared_buffer containing data. |
endp | Destination asio::ip::udp::endpoint for the buffer. |
true
if buffer written or queued for output, false
otherwise (no IO handler association, or IO handler stopped).
|
inline |
Send a reference counted buffer through the associated network IO handler.
This is a non-blocking call.
buf | chops::const_shared_buffer containing data. |
true
if buffer written or queued for output, false
otherwise (no IO handler association, or IO handler stopped).
|
inline |
Send a reference counted buffer to a specific destination endpoint (address and port), implemented only for UDP IO handlers.
This is a non-blocking call.
buf | chops::const_shared_buffer containing data. |
endp | Destination asio::ip::udp::endpoint for the buffer. |
true
if buffer written or queued for output, false
otherwise (no IO handler association, or IO handler stopped).
|
inline |
Send a buffer of data through the associated network IO handler.
The data is copied once into an internal reference counted buffer and then managed within the IO handler. This is a non-blocking call.
buf | Pointer to buffer. |
sz | Size of buffer. |
true
if buffer written or queued for output, false
otherwise (no IO handler association, or IO handler stopped).
|
inline |
Send a buffer to a specific destination endpoint (address and port), implemented only for UDP IO handlers.
Buffer data will be copied into an internal reference counted buffer. Calling this method is invalid for TCP IO handlers.
This is a non-blocking call.
buf | Pointer to buffer. |
sz | Size of buffer. |
endp | Destination asio::ip::udp::endpoint for the buffer. |
true
if buffer written or queued for output, false
otherwise (no IO handler association, or IO handler stopped).