Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::netio::Transceiver Class Reference

Network sender/receiver. More...

#include <transceiver.h>

Inheritance diagram for roc::netio::Transceiver:
Collaboration diagram for roc::netio::Transceiver:

Public Member Functions

 Transceiver (packet::PacketPool &packet_pool, core::BufferPool< uint8_t > &buffer_pool, core::IAllocator &allocator)
 Initialize. More...
 
virtual ~Transceiver ()
 Destroy. Stop all receivers and senders. More...
 
bool valid () const
 Check if transceiver was successfully constructed. More...
 
size_t num_ports () const
 Get number of receiver and sender ports. More...
 
bool add_udp_receiver (packet::Address &bind_address, packet::IWriter &writer)
 Add UDP datagram receiver port. More...
 
packet::IWriteradd_udp_sender (packet::Address &bind_address)
 Add UDP datagram sender port. More...
 
void remove_port (packet::Address bind_address)
 Remove sender or receiver port. Wait until port will be removed. More...
 

Detailed Description

Network sender/receiver.

Definition at line 36 of file transceiver.h.

Constructor & Destructor Documentation

roc::netio::Transceiver::Transceiver ( packet::PacketPool packet_pool,
core::BufferPool< uint8_t > &  buffer_pool,
core::IAllocator allocator 
)

Initialize.

Remarks
Start background thread if the object was successfully constructed.
virtual roc::netio::Transceiver::~Transceiver ( )
virtual

Destroy. Stop all receivers and senders.

Remarks
Wait until background thread finishes.

Member Function Documentation

bool roc::netio::Transceiver::add_udp_receiver ( packet::Address bind_address,
packet::IWriter writer 
)

Add UDP datagram receiver port.

Creates a new UDP receiver and bind it to bind_address. The receiver will pass packets to writer. Writer will be called from the network thread. It should not block.

If IP is zero, INADDR_ANY is used, i.e. the socket is bound to all network interfaces. If port is zero, a random free port is selected and written back to bind_address.

Returns
true on success or false if error occurred
packet::IWriter* roc::netio::Transceiver::add_udp_sender ( packet::Address bind_address)

Add UDP datagram sender port.

Creates a new UDP sender, bind to bind_address, and returns a writer that may be used to send packets from this address. Writer may be called from any thread. It will not block the caller.

If IP is zero, INADDR_ANY is used, i.e. the socket is bound to all network interfaces. If port is zero, a random free port is selected and written back to bind_address.

Returns
a new packet writer on success or null if error occurred
size_t roc::netio::Transceiver::num_ports ( ) const

Get number of receiver and sender ports.

void roc::netio::Transceiver::remove_port ( packet::Address  bind_address)

Remove sender or receiver port. Wait until port will be removed.

bool roc::netio::Transceiver::valid ( ) const

Check if transceiver was successfully constructed.


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