Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_transport
  6. pw::transport::Connector Class Reference
Loading...
Searching...
No Matches
pw::transport::Connector Class Referenceabstract

Overview

The establishing side of a datagram-oriented transport.

A connector opens outbound connections to a remote peer, performing any necessary protocol-level configuration and establishment, then provides a handle which is used to read to or write from that socket.

The Connector interface does not specify any addressing or ports, as those details are protocol-dependent. A concrete Connector instance should be constructed with and internally store any such state if required.

If a Connector is destructed, it must resolve any pending ConnectFuture objects with a FAILED_PRECONDITION.

Public Types

using ConnectFuture = async2::ValueFuture< Result< Socket > >
 

Public Member Functions

virtual ConnectFuture Connect ()=0
 

Static Protected Member Functions

static Socket WrapSocket (SocketImpl &impl)
 Creates a Socket handle from an implementation.
 

Member Typedef Documentation

◆ ConnectFuture

The future returned by Connect, resolving to a Socket handle on success.

Member Function Documentation

◆ Connect()

virtual ConnectFuture pw::transport::Connector::Connect ( )
pure virtual

Opens a connection to the peer, returning it once established.

It is up to the implementation to decide whether concurrent connections to the peer are allowed. If not supported, subsequent calls to Connect when a connection is active should return ALREADY_EXISTS. It must always be possible to call Connect again when no connections are active and the transport is still alive.

Returns
  • OK: The connection was established and is ready for use.
  • UNAVAILABLE: The peer could not be reached.
  • FAILED_PRECONDITION: The transport is permanently down.
  • ALREADY_EXISTS: A connection is already active and the transport does not support multiple simultaneous connections.
  • RESOURCE_EXHAUSTED: The socket object could not be allocated.

The documentation for this class was generated from the following file: