Woman, Life, Freedom


Async BSD Sockets Library
Library protected and public interface header documentation
AsyncBsdSocketLib::FifoReceiver Class Reference

FIFO (named pipe) IPC receiver (reader) More...

#include <fifo_receiver.h>

Inheritance diagram for AsyncBsdSocketLib::FifoReceiver:
AsyncBsdSocketLib::Communicator

Public Member Functions

 FifoReceiver (std::string pathname)
 Constructor. More...
 
int Connection () const noexcept override
 Connection descriptor for sending and receiving. More...
 
bool TrySetup () noexcept override
 Try to setup the communicator. More...
 
template<std::size_t N>
ssize_t Receive (std::array< uint8_t, N > &buffer) const noexcept
 Receive a byte array from the FIFO pipe. More...
 
- Public Member Functions inherited from AsyncBsdSocketLib::Communicator
int Descriptor () const noexcept
 File descriptor. More...
 
virtual bool TryClose () noexcept
 Try to close the communicator. More...
 

Additional Inherited Members

- Protected Attributes inherited from AsyncBsdSocketLib::Communicator
int FileDescriptor
 File descriptor.
 

Detailed Description

FIFO (named pipe) IPC receiver (reader)

Constructor & Destructor Documentation

◆ FifoReceiver()

AsyncBsdSocketLib::FifoReceiver::FifoReceiver ( std::string  pathname)

Constructor.

Parameters
pathnameFIFO file path

Member Function Documentation

◆ Connection()

int AsyncBsdSocketLib::FifoReceiver::Connection ( ) const
overridevirtualnoexcept

Connection descriptor for sending and receiving.

Returns
A non-negative value if there is a valid connection; otherwise -1

Implements AsyncBsdSocketLib::Communicator.

◆ Receive()

template<std::size_t N>
ssize_t AsyncBsdSocketLib::FifoReceiver::Receive ( std::array< uint8_t, N > &  buffer) const
inlinenoexcept

Receive a byte array from the FIFO pipe.

Template Parameters
NReceive buffer size
Parameters
bufferReceive buffer byte array
Returns
Size of received bytes (-1 in case of receiving failed)
Warning
Due to edge-triggered polling, starvation can occur

◆ TrySetup()

bool AsyncBsdSocketLib::FifoReceiver::TrySetup ( )
overridevirtualnoexcept

Try to setup the communicator.

Returns
True if the communicator is successfully set up; otherwise false

Implements AsyncBsdSocketLib::Communicator.