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

Connection interface. More...

#include <iconn.h>

Inheritance diagram for roc::netio::IConn:

Public Member Functions

virtual const address::SocketAddrlocal_address () const =0
 Return address of the local peer. More...
 
virtual const address::SocketAddrremote_address () const =0
 Return address of the remote peer. More...
 
virtual bool is_failed () const =0
 Return true if there was a failure. More...
 
virtual bool is_writable () const =0
 Return true if the connection is writable. More...
 
virtual bool is_readable () const =0
 Return true if the connection is readable. More...
 
virtual ssize_t try_write (const void *buf, size_t len)=0
 Try writing buf of size len to the connection without blocking. More...
 
virtual ssize_t try_read (void *buf, size_t len)=0
 Try reading len bytes from the the connection to buf without blocking. More...
 
virtual void async_terminate (TerminationMode mode)=0
 Initiate asynchronous connection termination. More...
 

Detailed Description

Connection interface.

All methods are thread-safe and non-blocking.

All methods are also lock-free if there is no more than one simultaneous writer or reader. IConn operations are never blocked by network thread itself, but concurrent simultaneous writes and reads block each other.

Definition at line 30 of file iconn.h.

Member Function Documentation

◆ async_terminate()

virtual void roc::netio::IConn::async_terminate ( TerminationMode  mode)
pure virtual

Initiate asynchronous connection termination.

Remarks
When termination is complete, IConnHandler::connection_terminated() is called, and then connection object is destroyed.

Implemented in roc::netio::TcpConnectionPort.

◆ is_failed()

virtual bool roc::netio::IConn::is_failed ( ) const
pure virtual

Return true if there was a failure.

Implemented in roc::netio::TcpConnectionPort.

◆ is_readable()

virtual bool roc::netio::IConn::is_readable ( ) const
pure virtual

Return true if the connection is readable.

Implemented in roc::netio::TcpConnectionPort.

◆ is_writable()

virtual bool roc::netio::IConn::is_writable ( ) const
pure virtual

Return true if the connection is writable.

Implemented in roc::netio::TcpConnectionPort.

◆ local_address()

virtual const address::SocketAddr& roc::netio::IConn::local_address ( ) const
pure virtual

Return address of the local peer.

Implemented in roc::netio::TcpConnectionPort.

◆ remote_address()

virtual const address::SocketAddr& roc::netio::IConn::remote_address ( ) const
pure virtual

Return address of the remote peer.

Implemented in roc::netio::TcpConnectionPort.

◆ try_read()

virtual ssize_t roc::netio::IConn::try_read ( void *  buf,
size_t  len 
)
pure virtual

Try reading len bytes from the the connection to buf without blocking.

Remarks
  • buf should not be NULL.
  • buf should have size at least of len bytes.
Returns
number of bytes read (>= 0) or SocketError (< 0);

Implemented in roc::netio::TcpConnectionPort.

◆ try_write()

virtual ssize_t roc::netio::IConn::try_write ( const void *  buf,
size_t  len 
)
pure virtual

Try writing buf of size len to the connection without blocking.

Remarks
  • buf should not be NULL.
  • buf should have size at least of len bytes.
Returns
number of bytes written (>= 0) or SocketError (< 0);

Implemented in roc::netio::TcpConnectionPort.


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