Stream backed by a connected TCP Socket.
More...
#include <network_stream.hpp>
|
| | TcpStream ()=default |
| | TcpStream (Socket &&connected) |
| | ~TcpStream () override |
| | TcpStream (TcpStream &&) noexcept |
| TcpStream & | operator= (TcpStream &&) noexcept |
| bool | connect (std::string_view host, std::uint16_t port) |
| StreamResult | read (std::uint8_t *buffer, std::size_t size) override |
| | Read up to size bytes into buffer.
|
| StreamResult | write (const std::uint8_t *buffer, std::size_t size) override |
| | Write up to size bytes from buffer.
|
| void | shutdown () |
| | Mark the stream closed and interrupt blocking I/O without releasing the socket handle.
|
| void | close () override |
| | Close the stream. Idempotent.
|
| bool | is_open () const override |
| | True while the stream is usable for read/write.
|
| Socket & | socket () |
| | Access the underlying socket (advanced use: set options, inspect fd).
|
Stream backed by a connected TCP Socket.
Construction is deliberately two-phase: connect(host, port) performs a blocking DNS + TCP handshake. Wrap in an AsyncStream to make it non-blocking for the caller.
◆ TcpStream() [1/3]
| pulp::runtime::TcpStream::TcpStream |
( |
| ) |
|
|
default |
◆ TcpStream() [2/3]
| pulp::runtime::TcpStream::TcpStream |
( |
Socket && | connected | ) |
|
|
explicit |
◆ ~TcpStream()
| pulp::runtime::TcpStream::~TcpStream |
( |
| ) |
|
|
override |
◆ TcpStream() [3/3]
| pulp::runtime::TcpStream::TcpStream |
( |
TcpStream && | | ) |
|
|
noexcept |
◆ close()
| void pulp::runtime::TcpStream::close |
( |
| ) |
|
|
overridevirtual |
◆ connect()
| bool pulp::runtime::TcpStream::connect |
( |
std::string_view | host, |
|
|
std::uint16_t | port ) |
◆ is_open()
| bool pulp::runtime::TcpStream::is_open |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ operator=()
◆ read()
| StreamResult pulp::runtime::TcpStream::read |
( |
std::uint8_t * | buffer, |
|
|
std::size_t | size ) |
|
overridevirtual |
Read up to size bytes into buffer.
Returns how many bytes were written, or an error. buffer may be partially filled on error.
Implements pulp::runtime::Stream.
◆ shutdown()
| void pulp::runtime::TcpStream::shutdown |
( |
| ) |
|
Mark the stream closed and interrupt blocking I/O without releasing the socket handle.
◆ socket()
| Socket & pulp::runtime::TcpStream::socket |
( |
| ) |
|
|
inline |
Access the underlying socket (advanced use: set options, inspect fd).
◆ write()
| StreamResult pulp::runtime::TcpStream::write |
( |
const std::uint8_t * | buffer, |
|
|
std::size_t | size ) |
|
overridevirtual |
Write up to size bytes from buffer.
Returns how many bytes were consumed. Partial writes are permitted — callers loop until satisfied or treat the short return as backpressure.
Implements pulp::runtime::Stream.
The documentation for this class was generated from the following file: