|
SatCat5
|
Copy bytes from a Readable source to a network address.
Given a buffered source of data and a maximum chunk size, read data in chunks and stream each chunk to a net::Address. The source is a byte-stream that ignores packet boundaries. For a similiar class that retains packet boundaries,
Usage is similar to BufferedCopy, but with improved controls for packetizing the raw stream. Two thresholds control the length of outgoing packets:
To prevent trailing data from becoming stuck, a timeout allows transmission of smaller chunks as follows. With N as the number of bytes available from the Readable source:
Definition at line 124 of file io_buffer.h.
#include <io_buffer.h>
Public Member Functions | |
| BufferedStream (satcat5::io::Readable *src, satcat5::net::Address *dst, unsigned max_chunk=512, unsigned min_txnow=UINT_MAX) | |
| Set source, destination, APID, and chunk-size. More... | |
| void | set_timeout (unsigned msec) |
| Set packetization timeout, in milliseconds. More... | |
Protected Member Functions | |
| void | data_rcvd (satcat5::io::Readable *src) override |
| The data_rcvd() callback is polled whenever data is available. More... | |
| void | data_unlink (satcat5::io::Readable *src) override |
| Unlink this EventListener from the designated source, because the designated Readable object is being destroyed. More... | |
Protected Attributes | |
| satcat5::io::Readable * | m_src |
| satcat5::net::Address *const | m_dst |
| const unsigned | m_max_chunk |
| const unsigned | m_min_txnow |
| unsigned | m_timeout_msec |
| satcat5::util::TimeVal | m_tref |
| BufferedStream::BufferedStream | ( | satcat5::io::Readable * | src, |
| satcat5::net::Address * | dst, | ||
| unsigned | max_chunk = 512, |
||
| unsigned | min_txnow = UINT_MAX |
||
| ) |
Set source, destination, APID, and chunk-size.
Default sets max_chunk to 512 bytes and ignores min_txnow.
Definition at line 51 of file io_buffer.cc.
|
overrideprotectedvirtual |
The data_rcvd() callback is polled whenever data is available.
A pointer is provided to assist handlers with multiple sources. Child objects of io::EventListener MUST override this method.
Implements satcat5::io::EventListener.
Definition at line 72 of file io_buffer.cc.
|
overrideprotectedvirtual |
Unlink this EventListener from the designated source, because the designated Readable object is being destroyed.
Child objects of io::EventListener MAY override this method if action is required.
Reimplemented from satcat5::io::EventListener.
Definition at line 99 of file io_buffer.cc.
|
inline |
Set packetization timeout, in milliseconds.
If the timeout is zero, copy only full-size chunks.
Definition at line 139 of file io_buffer.h.