Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_transport
Loading...
Searching...
No Matches
pw_transport

Overview

Asynchronous datagram-oriented transport interface.

Classes

struct  pw::transport::ForwardingDatagramSocketOptions
 Configuration for a ForwardingDatagramSocketPair. More...
 
class  pw::transport::ForwardingDatagramSocketPair
 
class  pw::transport::Socket
 
class  pw::transport::ReliableSocket
 
class  pw::transport::WriteReservation
 
class  pw::transport::ReadFuture
 Future representing receiving a single datagram from a Socket. More...
 
class  pw::transport::ReserveWriteFuture
 
class  pw::transport::CloseFuture
 Future representing waiting for a Socket to close. More...
 
class  pw::transport::SocketImpl
 
class  pw::transport::ReliableSocketImpl
 
class  pw::transport::Listener
 
class  pw::transport::ReliableListener
 
class  pw::transport::Connector
 
class  pw::transport::ReliableConnector
 

Functions

bool pw::transport::operator== (const Socket &lhs, const Socket &rhs)
 
bool pw::transport::operator!= (const Socket &lhs, const Socket &rhs)
 
 pw::transport::Socket::Socket (ReliableSocket &&other) noexcept
 
Socket & pw::transport::Socket::operator= (ReliableSocket &&other) noexcept
 
size_t pw::transport::Socket::max_write_message_size_bytes () const
 The maximum size in bytes that can be requested in a ReserveWrite.
 
size_t pw::transport::Socket::max_read_message_size_bytes () const
 The maximum size in bytes of a single datagram received from the peer.
 
ReadFuture pw::transport::Socket::Read () const
 
ReserveWriteFuture pw::transport::Socket::ReserveWrite (size_t min_size_bytes) const
 
std::optional< WriteReservation > pw::transport::Socket::TryReserveWrite (size_t min_size_bytes) const
 
CloseFuture pw::transport::Socket::Close () const
 
CloseFuture pw::transport::Socket::WhenClosed () const
 
ReadFuture pw::transport::ReliableSocket::Read () const
 
ReserveWriteFuture pw::transport::ReliableSocket::ReserveWrite (size_t min_size_bytes) const
 
std::optional< WriteReservation > pw::transport::ReliableSocket::TryReserveWrite (size_t min_size_bytes) const
 
CloseFuture pw::transport::ReliableSocket::Close () const
 
CloseFuture pw::transport::ReliableSocket::WhenClosed () const
 

Function Documentation

◆ Close() [1/2]

CloseFuture pw::transport::Socket::Close ( ) const
inline

Terminally closes the socket, resolving once it has been fully torn down. If the socket is already closed, this is a no-op.

◆ Close() [2/2]

CloseFuture pw::transport::ReliableSocket::Close ( ) const
inline

Terminally closes the socket, resolving once it has been fully torn down. If the socket is already closed, this is a no-op.

◆ Read() [1/2]

ReadFuture pw::transport::Socket::Read ( ) const
inline

Receives a single datagram from the peer, resolving to a ConstBuf view of its data. An empty (0-byte) datagram resolves to a non-null empty ConstBuf; a null ConstBuf indicates that the socket is closed.

Only one Read operation may be pended at a time. Pending a second ReadFuture while one is active will assert.

Warning
The returned ConstBuf is a view into memory provided by the transport and should be processed and destroyed as quickly as reasonably possible to avoid potential head-of-line blocking or exhaustion of transport buffers.

◆ Read() [2/2]

ReadFuture pw::transport::ReliableSocket::Read ( ) const
inline

Receives a single datagram from the peer, resolving to a ConstBuf view of its data. An empty (0-byte) datagram resolves to a non-null empty ConstBuf; a null ConstBuf indicates that the socket is closed.

Only one Read operation may be pended at a time. Pending a second ReadFuture while one is active will assert.

Warning
The returned ConstBuf is a view into memory provided by the transport and should be processed and destroyed as quickly as reasonably possible to avoid potential head-of-line blocking or exhaustion of transport buffers.

◆ ReserveWrite() [1/2]

ReserveWriteFuture pw::transport::Socket::ReserveWrite ( size_t  min_size_bytes) const
inline

Requests to write a datagram of size at least min_size_bytes, waiting for space to become available.

Resolves to a std::optional<WriteReservation> that allows writing to that buffer, or std::nullopt if the socket has closed.

Multiple reservations or reservation requests can be outstanding at once. If multiple pending requests exist, the order in which they are resolved is not specified.

Warning
Active reservations and pending requests consume transport resources. They should be committed, or canceled as quickly as possible to avoid buffer starvation and transmission stalls.

An empty datagram can be sent by requesting a size of 0. Requesting larger than max_write_message_size_bytes will assert.

◆ ReserveWrite() [2/2]

ReserveWriteFuture pw::transport::ReliableSocket::ReserveWrite ( size_t  min_size_bytes) const
inline

Requests to write a datagram of size at least min_size_bytes, waiting for space to become available.

Resolves to a std::optional<WriteReservation> that allows writing to that buffer, or std::nullopt if the socket has closed.

Multiple reservations or reservation requests can be outstanding at once. If multiple pending requests exist, the order in which they are resolved is not specified.

Warning
Active reservations and pending requests consume transport resources. They should be committed, or canceled as quickly as possible to avoid buffer starvation and transmission stalls.

An empty datagram can be sent by requesting a size of 0. Requesting larger than max_write_message_size_bytes will assert.

◆ TryReserveWrite() [1/2]

std::optional< WriteReservation > pw::transport::Socket::TryReserveWrite ( size_t  min_size_bytes) const
inline

Synchronously attempts to reserve space for writing a datagram of at least min_size_bytes.

Returns std::nullopt if space is not immediately available or if the socket is closed.

Warning
Active reservations and pending requests consume transport resources. They should be committed, or canceled as quickly as possible to avoid buffer starvation and transmission stalls.

An empty datagram can be sent by requesting a size of 0. Requesting larger than max_write_message_size_bytes will assert.

◆ TryReserveWrite() [2/2]

std::optional< WriteReservation > pw::transport::ReliableSocket::TryReserveWrite ( size_t  min_size_bytes) const
inline

Synchronously attempts to reserve space for writing a datagram of at least min_size_bytes.

Returns std::nullopt if space is not immediately available or if the socket is closed.

Warning
Active reservations and pending requests consume transport resources. They should be committed, or canceled as quickly as possible to avoid buffer starvation and transmission stalls.

An empty datagram can be sent by requesting a size of 0. Requesting larger than max_write_message_size_bytes will assert.

◆ WhenClosed() [1/2]

CloseFuture pw::transport::Socket::WhenClosed ( ) const
inline

Returns a future that resolves when the socket is terminally closed or disconnected.

◆ WhenClosed() [2/2]

CloseFuture pw::transport::ReliableSocket::WhenClosed ( ) const
inline

Returns a future that resolves when the socket is terminally closed or disconnected.