class PipeCommunication

Overview

Creates a pipe, used for inter-process communication. Currently used just in Tests. More…

#include <pipe_communication.h>

class PipeCommunication {
public:
    // methods

    ssize_t readP(
        void* buf,
        size_t count,
        u_int16_t tries = 1,
        u_int16_t sleepSecs = 0
    );

    ssize_t writeP(
        const void* buf,
        size_t count,
        u_int16_t tries = 1,
        u_int16_t sleepSecs = 0
    );

    void closeRead();
    void closeWrite();
    int readFd() const;
    int writeFd() const;
};

Detailed Documentation

Creates a pipe, used for inter-process communication. Currently used just in Tests.

Methods

ssize_t readP(
    void* buf,
    size_t count,
    u_int16_t tries = 1,
    u_int16_t sleepSecs = 0
)

Read from pipe.

Parameters:

buf

buffer to read to

count

Number of bytes to read

tries

How often to try to read from buffer

sleepSecs

How long to wait between retries

Returns:

-1 on error, else number of read bytes

ssize_t writeP(
    const void* buf,
    size_t count,
    u_int16_t tries = 1,
    u_int16_t sleepSecs = 0
)

Write to pipe.

Parameters:

buf

buffer to write from

count

Number of bytes to write

tries

How often to try to write from buffer

sleepSecs

How long to wait between retries

Returns:

-1 on error, else number of written bytes

void closeRead()

Close Read direction.

void closeWrite()

Close Write direction.

int readFd() const

Get Read File Descriptor.

int writeFd() const

Get Write File Descriptor.