Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::netio::BasicPort Class Referenceabstract

Base class for ports. More...

#include <basic_port.h>

Inheritance diagram for roc::netio::BasicPort:
Collaboration diagram for roc::netio::BasicPort:

Public Member Functions

 BasicPort (core::IArena &)
 Initialize. More...
 
virtual ~BasicPort ()
 Destroy. More...
 
const char * descriptor () const
 Get a human-readable port description. More...
 
virtual bool open ()=0
 Open port. More...
 
virtual AsyncOperationStatus async_close (ICloseHandler &handler, void *handler_arg)=0
 Asynchronous close. More...
 
- Public Member Functions inherited from roc::core::RefCounted< BasicPort, core::ArenaAllocation >
 RefCounted ()
 Initialize. More...
 
 RefCounted (const core::ArenaAllocation &policy)
 Initialize. More...
 
int getref () const
 Get reference counter. More...
 
void incref () const
 Increment reference counter. More...
 
void decref () const
 Decrement reference counter. More...
 
- Public Member Functions inherited from roc::core::ListNode
ListNodeDatalist_node_data () const
 Get list node data. More...
 

Protected Member Functions

void update_descriptor ()
 Format descriptor and store into internal buffer. More...
 
virtual void format_descriptor (core::StringBuilder &b)=0
 Implementation of descriptor formatting. More...
 
- Protected Member Functions inherited from roc::core::ArenaAllocation
IArenaarena () const
 Get arena. More...
 
 ArenaAllocation (IArena &arena)
 Initialize. More...
 
template<class T >
void destroy (T &object)
 Destroy object and return memory to arena. More...
 

Detailed Description

Base class for ports.

Port is a transport-level endpoint, sending or receiving data from remote peer, like UDP sender or receiver, TCP listening socket, or TCP connection.

The following rules must be followed:

  • if you called open(), you're responsible for calling async_close(), even if open() failed
  • if async_close() returned AsyncOp_Completed, the port was closed immediately, and you can now destroy it
  • if async_close() returned AsyncOp_Started, you should wait until close handler callback is invoked before destroying port

Definition at line 39 of file basic_port.h.

Constructor & Destructor Documentation

◆ BasicPort()

roc::netio::BasicPort::BasicPort ( core::IArena )
explicit

Initialize.

◆ ~BasicPort()

virtual roc::netio::BasicPort::~BasicPort ( )
virtual

Destroy.

Member Function Documentation

◆ async_close()

virtual AsyncOperationStatus roc::netio::BasicPort::async_close ( ICloseHandler handler,
void *  handler_arg 
)
pure virtual

Asynchronous close.

Remarks
Should be called from the event loop thread.
Returns
status code indicating whether operation was completed immediately or is scheduled for asynchronous execution

Implemented in roc::netio::UdpSenderPort, roc::netio::UdpReceiverPort, roc::netio::TcpServerPort, and roc::netio::TcpConnectionPort.

◆ descriptor()

const char* roc::netio::BasicPort::descriptor ( ) const

Get a human-readable port description.

Note
Port descriptor may change during initial configuration.

◆ format_descriptor()

virtual void roc::netio::BasicPort::format_descriptor ( core::StringBuilder b)
protectedpure virtual

◆ open()

virtual bool roc::netio::BasicPort::open ( )
pure virtual

Open port.

Remarks
Should be called from the event loop thread.

Implemented in roc::netio::UdpSenderPort, roc::netio::UdpReceiverPort, roc::netio::TcpServerPort, and roc::netio::TcpConnectionPort.

◆ update_descriptor()

void roc::netio::BasicPort::update_descriptor ( )
protected

Format descriptor and store into internal buffer.


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