Rudiments
Public Member Functions | Static Public Member Functions | List of all members
filedescriptor Class Reference

Inherits input, and output.

Inherited by client, file, serialport, server, and stdiofiledescriptor.

Public Member Functions

 filedescriptor ()
 
virtual ~filedescriptor ()
 
virtual bool close ()
 
int32_t getFileDescriptor ()
 
void setFileDescriptor (int32_t filedesc)
 
bool setIsStream (bool isstream)
 
bool getIsStream ()
 
int32_t duplicate ()
 
bool duplicate (int32_t newfd)
 
void setSocketLayer (socketlayer *layer)
 
socketlayergetSocketLayer ()
 
virtual bool supportsBlockingAndNonBlockingModes ()
 
virtual bool setNonBlockingMode (bool usenonblockingmode)
 
virtual bool getNonBlockingMode ()
 
virtual off64_t getPosition ()
 
virtual off64_t setPositionRelativeToBeginning (off64_t offset)
 
virtual off64_t setPositionRelativeToCurrent (off64_t offset)
 
virtual off64_t setPositionRelativeToEnd (off64_t offset)
 
ssize_t write (uint16_t number)
 
ssize_t write (uint32_t number)
 
ssize_t write (uint64_t number)
 
ssize_t write (int16_t number)
 
ssize_t write (int32_t number)
 
ssize_t write (int64_t number)
 
ssize_t write (float number)
 
ssize_t write (double number)
 
ssize_t write (byte_t character)
 
ssize_t write (char character)
 
ssize_t write (wchar_t character)
 
ssize_t writeUcs2 (ucs2_t character)
 
ssize_t write (bool value)
 
ssize_t write (const byte_t *string)
 
ssize_t write (const char *string)
 
ssize_t write (const wchar_t *string)
 
ssize_t writeUcs2 (const ucs2_t *string)
 
ssize_t write (const byte_t *string, size_t size)
 
ssize_t write (const char *string, size_t length)
 
ssize_t write (const wchar_t *string, size_t length)
 
ssize_t writeUcs2 (const ucs2_t *string, size_t length)
 
ssize_t write (const void *buffer, size_t size)
 
ssize_t write (uint16_t number, int32_t sec, int32_t usec)
 
ssize_t write (uint32_t number, int32_t sec, int32_t usec)
 
ssize_t write (uint64_t number, int32_t sec, int32_t usec)
 
ssize_t write (int16_t number, int32_t sec, int32_t usec)
 
ssize_t write (int32_t number, int32_t sec, int32_t usec)
 
ssize_t write (int64_t number, int32_t sec, int32_t usec)
 
ssize_t write (float number, int32_t sec, int32_t usec)
 
ssize_t write (double number, int32_t sec, int32_t usec)
 
ssize_t write (byte_t character, int32_t sec, int32_t usec)
 
ssize_t write (char character, int32_t sec, int32_t usec)
 
ssize_t write (wchar_t character, int32_t sec, int32_t usec)
 
ssize_t writeUcs2 (ucs2_t character, int32_t sec, int32_t usec)
 
ssize_t write (bool value, int32_t sec, int32_t usec)
 
ssize_t write (const byte_t *string, int32_t sec, int32_t usec)
 
ssize_t write (const char *string, int32_t sec, int32_t usec)
 
ssize_t write (const wchar_t *string, int32_t sec, int32_t usec)
 
ssize_t writeUcs2 (const ucs2_t *string, int32_t sec, int32_t usec)
 
ssize_t write (const byte_t *string, size_t size, int32_t sec, int32_t usec)
 
ssize_t write (const char *string, size_t length, int32_t sec, int32_t usec)
 
ssize_t write (const wchar_t *string, size_t length, int32_t sec, int32_t usec)
 
ssize_t writeUcs2 (const ucs2_t *string, size_t length, int32_t sec, int32_t usec)
 
ssize_t write (const void *buffer, size_t size, int32_t sec, int32_t usec)
 
ssize_t read (uint16_t *buffer)
 
ssize_t read (uint32_t *buffer)
 
ssize_t read (uint64_t *buffer)
 
ssize_t read (int16_t *buffer)
 
ssize_t read (int32_t *buffer)
 
ssize_t read (int64_t *buffer)
 
ssize_t read (float *buffer)
 
ssize_t read (double *buffer)
 
ssize_t read (byte_t *buffer)
 
ssize_t read (char *buffer)
 
ssize_t read (wchar_t *buffer)
 
ssize_t readUcs2 (ucs2_t *buffer)
 
ssize_t read (bool *buffer)
 
ssize_t read (byte_t *buffer, size_t size)
 
ssize_t read (char *buffer, size_t length)
 
ssize_t read (wchar_t *buffer, size_t length)
 
ssize_t readUcs2 (ucs2_t *buffer, size_t length)
 
ssize_t read (void *buf, size_t size)
 
ssize_t read (char **buffer, const char *terminator)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes)
 
ssize_t read (uint16_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (uint32_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (uint64_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (int16_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (int32_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (int64_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (float *buffer, int32_t sec, int32_t usec)
 
ssize_t read (double *buffer, int32_t sec, int32_t usec)
 
ssize_t read (byte_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (char *buffer, int32_t sec, int32_t usec)
 
ssize_t read (wchar_t *buffer, int32_t sec, int32_t usec)
 
ssize_t readUcs2 (ucs2_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (bool *buffer, int32_t sec, int32_t usec)
 
ssize_t read (byte_t *buffer, size_t size, int32_t sec, int32_t usec)
 
ssize_t read (char *buffer, size_t length, int32_t sec, int32_t usec)
 
ssize_t read (wchar_t *buffer, size_t length, int32_t sec, int32_t usec)
 
ssize_t readUcs2 (ucs2_t *buffer, size_t length, int32_t sec, int32_t usec)
 
ssize_t read (void *buf, size_t size, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, char escapechar, int32_t sec, int32_t usec)
 
int32_t waitForNonBlockingRead (int32_t sec, int32_t usec)
 
int32_t waitForNonBlockingWrite (int32_t sec, int32_t usec)
 
void setRetryInterruptedReads (bool retry)
 
bool getRetryInterruptedReads ()
 
void setRetryInterruptedWrites (bool retry)
 
bool getRetryInterruptedWrites ()
 
void setRetryInterruptedWaits (bool retry)
 
bool getRetryInterruptedWaits ()
 
void setRetryInterruptedFcntl (bool retry)
 
bool getRetryInterruptedFcntl ()
 
void setRetryInterruptedIoctl (bool retry)
 
bool getRetryInterruptedIoctl ()
 
void setAllowShortReads (bool allow)
 
bool getAllowShortReads ()
 
void setAllowShortWrites (bool allow)
 
bool getAllowShortWrites ()
 
virtual bool passFileDescriptor (int32_t fd)
 
virtual bool receiveFileDescriptor (int32_t *fd)
 
virtual bool passSocket (int32_t sock)
 
virtual bool receiveSocket (int32_t *sock)
 
void setTranslateByteOrder (bool translate)
 
bool getTranslateByteOrder ()
 
virtual int32_t fCntl (int32_t command, long arg)
 
virtual int32_t ioCtl (int32_t command, void *arg)
 
bool setNaglesAlgorithmEnabled (bool enabled)
 
bool getNaglesAlgorithmEnabled ()
 
bool setSocketWriteBufferSize (int32_t size)
 
bool getSocketWriteBufferSize (int32_t *size)
 
bool setSocketReadBufferSize (int32_t size)
 
bool getSocketReadBufferSize (int32_t *size)
 
bool disableIPv4 ()
 
bool enableIPv4 ()
 
const char * getType ()
 
char * getPeerAddress ()
 
bool setWriteBufferSize (size_t size)
 
size_t getWriteBufferSize ()
 
bool flushWriteBuffer (int32_t sec, int32_t usec)
 
bool setReadBufferSize (size_t size)
 
size_t getReadBufferSize ()
 
void setMmapBufferingEnabled (bool enabled)
 
bool getMmapBufferingEnabled ()
 
bool isCurrentBlockMmapBuffered ()
 
off64_t getCurrentBlockOffset ()
 
bool setCloseOnExec (bool close)
 
bool getCloseOnExec ()
 
- Public Member Functions inherited from input
 input ()
 
virtual ~input ()
 
ssize_t read (char **buffer, const char *terminator)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes)
 
ssize_t read (char **buffer, const char *terminator, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, char escapechar, int32_t sec, int32_t usec)
 
- Public Member Functions inherited from object
virtual ~object ()
 
- Public Member Functions inherited from output
 output ()
 
virtual ~output ()
 
virtual ssize_t printf (const char *format,...)
 
virtual ssize_t printf (const char *format, va_list *argp)
 
virtual ssize_t printf (const wchar_t *format,...)
 
virtual ssize_t printf (const wchar_t *format, va_list *argp)
 
virtual ssize_t printfUcs2 (const ucs2_t *format,...)
 
virtual ssize_t printfUcs2 (const ucs2_t *format, va_list *argp)
 
void safePrint (byte_t c)
 
void safePrint (const byte_t *str)
 
void safePrint (const byte_t *str, int32_t length)
 
void safePrint (char c)
 
void safePrint (const char *str)
 
void safePrint (const char *str, int32_t length)
 
void printBits (byte_t value)
 
void printBits (uint16_t value)
 
void printBits (uint32_t value)
 
void printBits (uint64_t value)
 
void printBits (char value)
 
void printBits (int16_t value)
 
void printBits (int32_t value)
 
void printBits (int64_t value)
 
void printBits (const byte_t *bits, uint64_t size)
 
void printHex (const byte_t *data, uint64_t size)
 
void printHex (const byte_t *data, uint64_t size, uint16_t indent)
 

Static Public Member Functions

static bool supportsPassAndReceiveFileDescriptor ()
 
static bool supportsPassAndReceiveSocket ()
 
static bool createPipe (filedescriptor *readfd, filedescriptor *writefd)
 
static uint16_t convertHostToNet (uint16_t value)
 
static uint32_t convertHostToNet (uint32_t value)
 
static uint64_t convertHostToNet (uint64_t value)
 
static uint16_t convertNetToHost (uint16_t value)
 
static uint32_t convertNetToHost (uint32_t value)
 
static uint64_t convertNetToHost (uint64_t value)
 
static uint16_t convertHostToLittleEndian (uint16_t value)
 
static uint32_t convertHostToLittleEndian (uint32_t value)
 
static uint64_t convertHostToLittleEndian (uint64_t value)
 
static uint16_t convertLittleEndianToHost (uint16_t value)
 
static uint32_t convertLittleEndianToHost (uint32_t value)
 
static uint64_t convertLittleEndianToHost (uint64_t value)
 

Detailed Description

The filedescriptor class extends the input and output classes, providing a base class for child classes that utilize file descriptors.

Constructor & Destructor Documentation

◆ filedescriptor()

filedescriptor::filedescriptor ( )

Creates an instance of the filedescriptor class.

◆ ~filedescriptor()

virtual filedescriptor::~filedescriptor ( )
virtual

Deletes this instance of the filedescriptor class. Calls close() if it hasn't already been called.

Member Function Documentation

◆ close()

virtual bool filedescriptor::close ( )
virtual

Closes the file descriptor. Returns true on success and false on failure.

Reimplemented in unixsocketserver, unixsocketclient, modemserver, and modemclient.

◆ convertHostToLittleEndian() [1/3]

static uint16_t filedescriptor::convertHostToLittleEndian ( uint16_t  value)
static

Converts an unsigned 16-bit integer from host byte order to little-endian byte order.

◆ convertHostToLittleEndian() [2/3]

static uint32_t filedescriptor::convertHostToLittleEndian ( uint32_t  value)
static

Converts an unsigned 32-bit integer from host byte order to little-endian byte order.

◆ convertHostToLittleEndian() [3/3]

static uint64_t filedescriptor::convertHostToLittleEndian ( uint64_t  value)
static

Converts an unsigned 64-bit integer from host byte order to little-endian byte order.

◆ convertHostToNet() [1/3]

static uint16_t filedescriptor::convertHostToNet ( uint16_t  value)
static

Converts an unsigned 16-bit integer from host byte order to network byte order (big-endian).

◆ convertHostToNet() [2/3]

static uint32_t filedescriptor::convertHostToNet ( uint32_t  value)
static

Converts an unsigned 32-bit integer from host byte order to network byte order (big-endian).

◆ convertHostToNet() [3/3]

static uint64_t filedescriptor::convertHostToNet ( uint64_t  value)
static

Converts an unsigned 64-bit integer from host byte order to network byte order (big-endian).

◆ convertLittleEndianToHost() [1/3]

static uint16_t filedescriptor::convertLittleEndianToHost ( uint16_t  value)
static

Converts an unsigned 16-bit integer from little-endian byte order to host byte order.

◆ convertLittleEndianToHost() [2/3]

static uint32_t filedescriptor::convertLittleEndianToHost ( uint32_t  value)
static

Converts an unsigned 32-bit integer from little-endian byte order to host byte order.

◆ convertLittleEndianToHost() [3/3]

static uint64_t filedescriptor::convertLittleEndianToHost ( uint64_t  value)
static

Converts an unsigned 64-bit integer from little-endian byte order to host byte order.

◆ convertNetToHost() [1/3]

static uint16_t filedescriptor::convertNetToHost ( uint16_t  value)
static

Converts an unsigned 16-bit integer from network byte order (bit-endian) to host byte order.

◆ convertNetToHost() [2/3]

static uint32_t filedescriptor::convertNetToHost ( uint32_t  value)
static

Converts an unsigned 32-bit integer from network byte order (bit-endian) to host byte order.

◆ convertNetToHost() [3/3]

static uint64_t filedescriptor::convertNetToHost ( uint64_t  value)
static

Converts an unsigned 64-bit integer from network byte order (bit-endian) to host byte order.

◆ createPipe()

static bool filedescriptor::createPipe ( filedescriptor readfd,
filedescriptor writefd 
)
static

Creates a pipe and sets "readfd" to the read side and "writefd" to the write side.

◆ disableIPv4()

bool filedescriptor::disableIPv4 ( )

Disables IPv4 on this file descriptor, only IPv6 will be used. This is only useful for TCP Socket file descriptors. Returns true on success and false on failure.

◆ duplicate() [1/2]

int32_t filedescriptor::duplicate ( )

Duplicates the file descriptor and returns the handle of the duplicate descriptor. The old and new descriptors may be used interchangeably, they share locks, position pointers, flags (except the close-on-exec flag), etc.

Returns the lowest-numbered unused descriptor on success or -1 on failure.

◆ duplicate() [2/2]

bool filedescriptor::duplicate ( int32_t  newfd)

Sets file descriptor handle "newfd" to be a duplicate of this file descriptor. If "newfd" is already open, it will be closed first.

Returns true on success and false on failure.

◆ enableIPv4()

bool filedescriptor::enableIPv4 ( )

Enables IPv4 (in addition to IPv6) on this file descriptor (the default). This is only useful for TCP Socket file descriptors. Returns true on success and false on failure.

◆ fCntl()

virtual int32_t filedescriptor::fCntl ( int32_t  command,
long  arg 
)
virtual

Use the fcntl() system call to perform various low-level file descriptor operations.

◆ flushWriteBuffer()

bool filedescriptor::flushWriteBuffer ( int32_t  sec,
int32_t  usec 
)

When write buffering enabled, this method causes the contents of the write buffer to be written to the file descriptor immediately. See setWriteBufferSize().

Returns true on success and false on failure.

If the buffer cannot be flushed within "sec" seconds and "usec" microseconds, then the method will fail. Set either "sec" or "usec" to -1 to disable the timeout and allow the method to block until the buffer has been flushed.

◆ getAllowShortReads()

bool filedescriptor::getAllowShortReads ( )

Returns true if read()s will attempt to read the specified number of bytes from the file descriptor, even if several passes are necessary, and false otherwise.

◆ getAllowShortWrites()

bool filedescriptor::getAllowShortWrites ( )

Returns true if read()s will attempt to read the specified number of bytes from the file descriptor, even if several passes are necessary, and false otherwise.

◆ getCloseOnExec()

bool filedescriptor::getCloseOnExec ( )

Returns true if the file descriptor will remain open across a process::exec() call and false otherwise.

◆ getCurrentBlockOffset()

off64_t filedescriptor::getCurrentBlockOffset ( )

If buffering is enabled, and this is a storage filedescriptor such as a file or raw block device. then this returns the offset of the currently buffered block, or 0 otherwise.

◆ getFileDescriptor()

int32_t filedescriptor::getFileDescriptor ( )

Returns the file descriptor.

◆ getIsStream()

bool filedescriptor::getIsStream ( )

Returns true if this filedescriptor was set to be a stream using setIsStream() or false otherwise.

◆ getMmapBufferingEnabled()

bool filedescriptor::getMmapBufferingEnabled ( )

Returns true if mmap will be used when buffering a storage filedescriptor such as a file or raw block device, or false otherwise. See setWriteBufferSize()/ setReadBufferSize().

◆ getNaglesAlgorithmEnabled()

bool filedescriptor::getNaglesAlgorithmEnabled ( )

Returns true if small write()s will be collected up and sent together when either the kernel's write buffer is full or when a maximum of 0.2 seconds has gone by, per Nagle's algorithm, or false if writes will be sent immediately.

◆ getNonBlockingMode()

virtual bool filedescriptor::getNonBlockingMode ( )
virtual

Returns true if the file descriptor is in non-blocking mode and false otherwise.

Reimplemented in socketserver, and socketclient.

◆ getPeerAddress()

char* filedescriptor::getPeerAddress ( )

Returns the IP address of the client at the other end of the connection if the filedescriptor is an inet socket or NULL otherwise.

Note that the buffer for the address is allocated internally and must be freed by the calling program.

◆ getPosition()

virtual off64_t filedescriptor::getPosition ( )
virtual

Returns the position (relative to the beginning of the file descriptor) at which the next read or write will occur, or -1 on failure.

Reimplemented from input.

◆ getReadBufferSize()

size_t filedescriptor::getReadBufferSize ( )

Returns the current size of the read buffer.

◆ getRetryInterruptedFcntl()

bool filedescriptor::getRetryInterruptedFcntl ( )

Returns true if interrupted calls to fcntl will be retried and false otherwise.

◆ getRetryInterruptedIoctl()

bool filedescriptor::getRetryInterruptedIoctl ( )

Returns true if interrupted calls to ioctl will be retried and false otherwise.

◆ getRetryInterruptedReads()

bool filedescriptor::getRetryInterruptedReads ( )

Returns true if interrupted reads will be retried and false otherwise.

◆ getRetryInterruptedWaits()

bool filedescriptor::getRetryInterruptedWaits ( )

Returns true if interrupted waits will be retried and false otherwise.

◆ getRetryInterruptedWrites()

bool filedescriptor::getRetryInterruptedWrites ( )

Returns true if interrupted writes will be retried and false otherwise.

◆ getSocketLayer()

socketlayer* filedescriptor::getSocketLayer ( )

Returns the socketlayer currently associated with the filedescriptor or NULL if none is currently associated.

◆ getSocketReadBufferSize()

bool filedescriptor::getSocketReadBufferSize ( int32_t *  size)

Fetches the size of the kernel's socket read buffer (in bytes) into buffer "size". This is only useful for socket file descriptors. Returns true on success and false on failure.

◆ getSocketWriteBufferSize()

bool filedescriptor::getSocketWriteBufferSize ( int32_t *  size)

Fetches the size of the kernel's socket write buffer (in bytes) into buffer "size". This is only useful for socket file descriptors. Returns true on success and false on failure.

◆ getTranslateByteOrder()

bool filedescriptor::getTranslateByteOrder ( )

Returns true if integers will be translated from native byte order to network byte order during writes and vice-versa during reads, and false otherwise.

◆ getType()

const char* filedescriptor::getType ( )

Returns a string representing the type of the filedescriptor. This is "filedescriptor" by default but a child class may override this method and return something else.

◆ getWriteBufferSize()

size_t filedescriptor::getWriteBufferSize ( )

Returns the current size of the write buffer.

◆ ioCtl()

virtual int32_t filedescriptor::ioCtl ( int32_t  command,
void *  arg 
)
virtual

Use the ioctl() system call to perform various low-level file descriptor operations.

Reimplemented in socketserver, and socketclient.

◆ isCurrentBlockMmapBuffered()

bool filedescriptor::isCurrentBlockMmapBuffered ( )

Returns true if this is a storage filedescriptor such as a file, raw block device, etc. and the current block is buffered using mmap, or false otherwise.

◆ passFileDescriptor()

virtual bool filedescriptor::passFileDescriptor ( int32_t  fd)
virtual

Sends file descriptor "fd" to the file descriptor. This is useful for passing an open file descriptor from one process to another over a unix socket, for example.

◆ passSocket()

virtual bool filedescriptor::passSocket ( int32_t  sock)
virtual

Sends socket "sock" to the file descriptor. This is useful for passing an open socket from one process to another over a unix socket, for example.

◆ read() [1/37]

ssize_t filedescriptor::read ( bool buffer)
inline

Reads a boolean value from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

◆ read() [2/37]

ssize_t filedescriptor::read ( bool buffer,
int32_t  sec,
int32_t  usec 
)
inline

Reads a boolean value from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

◆ read() [3/37]

ssize_t filedescriptor::read ( byte_t *  buffer)
inlinevirtual

Reads a byte from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [4/37]

ssize_t filedescriptor::read ( byte_t *  buffer,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads a byte from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [5/37]

ssize_t filedescriptor::read ( byte_t *  buffer,
size_t  size 
)
inlinevirtual

Reads "size" bytes from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [6/37]

ssize_t filedescriptor::read ( byte_t *  buffer,
size_t  size,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads "size" bytes from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [7/37]

ssize_t filedescriptor::read ( char **  buffer,
const char *  terminator 
)
inline

Reads from the file desciptor into "buffer" until "terminator" is encountered.

Note that "buffer" is allocated internally and must be freed by the calling program.

Returns the number of bytes that were read or RESULT_ERROR if an error occurred.

◆ read() [8/37]

ssize_t filedescriptor::read ( char **  buffer,
const char *  terminator,
int32_t  sec,
int32_t  usec 
)
inline

Reads from the file desciptor into "buffer" until "terminator" is encountered with a timeout of "sec" seconds and "usec" microseconds.

Note that "buffer" is allocated internally and must be freed by the calling program.

Returns the number of bytes that were read or RESULT_ERROR if an error occurred.

◆ read() [9/37]

ssize_t filedescriptor::read ( char **  buffer,
const char *  terminator,
size_t  maxbytes 
)
inline

Reads from the file desciptor into "buffer" until "terminator" is encountered.

Note that "buffer" is allocated internally and must be freed by the calling program.

Returns the number of bytes that were read, RESULT_ERROR if an error occurred or RESULT_MAX if maxbytes were read before the terminator was encountered.

Setting maxbytes to 0 disables it.

◆ read() [10/37]

ssize_t filedescriptor::read ( char **  buffer,
const char *  terminator,
size_t  maxbytes,
char  escapechar,
int32_t  sec,
int32_t  usec 
)
inline

Reads from the file desciptor into "buffer" until "terminator" is encountered, using "escapechar" as an escape character, with a timeout of "sec" seconds and "usec" microseconds.

Note that "buffer" is allocated internally and must be freed by the calling program.

Setting "escapechar" to '\0' disables it.

Returns the number of bytes that were read, RESULT_ERROR if an error occurred or RESULT_MAX if maxbytes were read before the terminator was encountered.

Setting maxbytes to 0 disables it.

◆ read() [11/37]

ssize_t filedescriptor::read ( char **  buffer,
const char *  terminator,
size_t  maxbytes,
int32_t  sec,
int32_t  usec 
)
inline

Reads from the file desciptor into "buffer" until "terminator" is encountered with a timeout of "sec" seconds and "usec" microseconds.

Note that "buffer" is allocated internally and must be freed by the calling program.

Returns the number of bytes that were read, RESULT_ERROR if an error occurred or RESULT_MAX if maxbytes were read before the terminator was encountered.

Setting maxbytes to 0 disables it.

◆ read() [12/37]

ssize_t filedescriptor::read ( char *  buffer)
inlinevirtual

Reads a character from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [13/37]

ssize_t filedescriptor::read ( char *  buffer,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads a character from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [14/37]

ssize_t filedescriptor::read ( char *  buffer,
size_t  length 
)
inlinevirtual

Reads "length" characters from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [15/37]

ssize_t filedescriptor::read ( char *  buffer,
size_t  length,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads "length" characters from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [16/37]

ssize_t filedescriptor::read ( double *  buffer)
inlinevirtual

Reads a double-precision floating point number from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [17/37]

ssize_t filedescriptor::read ( double *  buffer,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads a double-precision floating point number from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [18/37]

ssize_t filedescriptor::read ( float *  buffer)
inlinevirtual

Reads a floating point number from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [19/37]

ssize_t filedescriptor::read ( float *  buffer,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads a floating point number from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [20/37]

ssize_t filedescriptor::read ( int16_t *  buffer)
virtual

Reads a 16-bit integer from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [21/37]

ssize_t filedescriptor::read ( int16_t *  buffer,
int32_t  sec,
int32_t  usec 
)
virtual

Reads a 16-bit integer from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [22/37]

ssize_t filedescriptor::read ( int32_t *  buffer)
virtual

Reads a 32-bit integer from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [23/37]

ssize_t filedescriptor::read ( int32_t *  buffer,
int32_t  sec,
int32_t  usec 
)
virtual

Reads a 32-bit integer from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [24/37]

ssize_t filedescriptor::read ( int64_t *  buffer)
virtual

Reads a 64-bit integer from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [25/37]

ssize_t filedescriptor::read ( int64_t *  buffer,
int32_t  sec,
int32_t  usec 
)
virtual

Reads a 64-bit integer from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [26/37]

ssize_t filedescriptor::read ( uint16_t *  buffer)
virtual

Reads an unsigned 16-bit integer from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [27/37]

ssize_t filedescriptor::read ( uint16_t *  buffer,
int32_t  sec,
int32_t  usec 
)
virtual

Reads an unsigned 16-bit integer from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [28/37]

ssize_t filedescriptor::read ( uint32_t *  buffer)
virtual

Reads an unsigned 32-bit integer from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [29/37]

ssize_t filedescriptor::read ( uint32_t *  buffer,
int32_t  sec,
int32_t  usec 
)
virtual

Reads an unsigned 32-bit integer from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [30/37]

ssize_t filedescriptor::read ( uint64_t *  buffer)
virtual

Reads an unsigned 64-bit integer from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [31/37]

ssize_t filedescriptor::read ( uint64_t *  buffer,
int32_t  sec,
int32_t  usec 
)
virtual

Reads an unsigned 64-bit integer from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [32/37]

ssize_t filedescriptor::read ( void *  buf,
size_t  size 
)
inline

Reads "size" bytes from the file descriptor into "buf". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

◆ read() [33/37]

ssize_t filedescriptor::read ( void *  buf,
size_t  size,
int32_t  sec,
int32_t  usec 
)
inline

Reads "size" bytes from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

◆ read() [34/37]

ssize_t filedescriptor::read ( wchar_t *  buffer)
inlinevirtual

Reads a character from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [35/37]

ssize_t filedescriptor::read ( wchar_t *  buffer,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads a character from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ read() [36/37]

ssize_t filedescriptor::read ( wchar_t *  buffer,
size_t  length 
)
inlinevirtual

Reads "length" characters from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ read() [37/37]

ssize_t filedescriptor::read ( wchar_t *  buffer,
size_t  length,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads "length" characters from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ readUcs2() [1/4]

ssize_t filedescriptor::readUcs2 ( ucs2_t *  buffer)
inlinevirtual

Reads a character from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ readUcs2() [2/4]

ssize_t filedescriptor::readUcs2 ( ucs2_t *  buffer,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads a character from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ readUcs2() [3/4]

ssize_t filedescriptor::readUcs2 ( ucs2_t *  buffer,
size_t  length 
)
inlinevirtual

Reads "length" characters from the file descriptor into "buffer". Returns the number of bytes that were successfully read or RESULT_ERROR if an error occurred.

Implements input.

◆ readUcs2() [4/4]

ssize_t filedescriptor::readUcs2 ( ucs2_t *  buffer,
size_t  length,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Reads "length" characters from the file descriptor into "buffer" with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully read, RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from input.

◆ receiveFileDescriptor()

virtual bool filedescriptor::receiveFileDescriptor ( int32_t *  fd)
virtual

Receives a file descriptor into buffer "fd". This is useful for receiving an open file descriptor passed from another process over a unix socket, for example.

◆ receiveSocket()

virtual bool filedescriptor::receiveSocket ( int32_t *  sock)
virtual

Receives a socket into buffer "sock". This is useful for receiving an open file descriptor passed from another process over a unix socket, for example.

◆ setAllowShortReads()

void filedescriptor::setAllowShortReads ( bool  allow)

If "allow" is set true then read() will only attempt a single pass and return the number of bytes that were read during that pass whether the specified number of bytes were read or not.

If "allow" is set false then read() will attempt to read the specified number of bytes from the file descriptor, even if several passes are necessary.

Defaults to false.

◆ setAllowShortWrites()

void filedescriptor::setAllowShortWrites ( bool  allow)

If "allow" is set true then write() will only attempt a single pass and return the number of bytes that were written during that pass whether the specified number of bytes were written or not.

If "allow" is set false then write() will attempt to write the specified number of bytes to the file descriptor, even if several passes are necessary.

Defaults to false.

◆ setCloseOnExec()

bool filedescriptor::setCloseOnExec ( bool  close)

If "close" is true then the file descriptor will remain open across a process::exec() call. If "close" is false then the file descriptor will be closed during a process::exec() call.

Defaults to false.

◆ setFileDescriptor()

void filedescriptor::setFileDescriptor ( int32_t  filedesc)

Sets the file descriptor associated with the class to "filedesc".

◆ setIsStream()

bool filedescriptor::setIsStream ( bool  isstream)

Set "isstream" to true (the default) if this filedescriptor is a stream such as a socket, serial port, fifo, etc. or false if this filedescriptor is storage such as a file or raw block device. This setting impacts how buffering works, as well as how the various setPosition*() and getPosition() methods work.

Note that if the file descriptor is a stream, but this is set false, or vice versa, then unexpected results may occur if buffering is used, and/or the setPosition*()/getPosition() methods are called.

Note that this method to have any effect, it must be called when buffering is disabled. It must be called immedaiately upon creation of the instance, when buffering is disabled implicitly, or after a set of calls to disable buffering. For example:

setReadBufferSize(0); setWriteBufferSize(0); setIsStream(false);

Returns true on success or false if called while buffering is enabled.

◆ setMmapBufferingEnabled()

void filedescriptor::setMmapBufferingEnabled ( bool  enabled)

If "enabled" is set true then mmap will be used when buffering a storage filedescriptor such as a file or raw block device. If set false, then traditional buffering will be used. See setWriteBufferSize()/setReadBufferSize().

Note that on platforms with modern file caching, traditional buffering tends to outperform mmap buffering except in very specific situations such as when O_DIRECT is used to bypass the cache, when using large buffer sizes, or when randomly accessing small parts of large files.

NOTE: if memorymap::isSupported() returns false, then calling this method with "enabled" set to true has no effect.

Defaults to false.

◆ setNaglesAlgorithmEnabled()

bool filedescriptor::setNaglesAlgorithmEnabled ( bool  enabled)

If "enabled" is set true then small write()s will be collected up and sent together when either the kernel's write buffer is full or when a maximum of 0.2 seconds has gone by, per Nagle's algorithm.

If "enabled" is set false then writes will be sent immediately.

Defaults to true.

Returns true on success and false on failure.

◆ setNonBlockingMode()

virtual bool filedescriptor::setNonBlockingMode ( bool  usenonblockingmode)
virtual

If "usenonblockingmode" is true then the file descriptor put into in non-blocking mode. If "usenonblockingmode" is false then the file descriptor is put into blocking mode.

The default for most file descriptors is to be in blocking mode, however this is not guaranteed. It is good practice to specifically set the mode.

Returns true on success and false on failure.

Returns false if the system doesn't support blocking/nonblocking modes.

Reimplemented in socketserver, and socketclient.

◆ setPositionRelativeToBeginning()

virtual off64_t filedescriptor::setPositionRelativeToBeginning ( off64_t  offset)
virtual

Sets the position (relative to the beginning of the file descriptor) at which the next read or write will occur to "offset". Returns that position on success or -1 on failure.

Reimplemented from input.

◆ setPositionRelativeToCurrent()

virtual off64_t filedescriptor::setPositionRelativeToCurrent ( off64_t  offset)
virtual

Advances the position at which the next read or write will occur by "offset" bytes. Returns that position on success or -1 on failure.

Reimplemented from input.

◆ setPositionRelativeToEnd()

virtual off64_t filedescriptor::setPositionRelativeToEnd ( off64_t  offset)
virtual

Sets the position at which the next read or write will occur to the end of the file plus "offset" bytes. Generally, "offset" will be negative though most filesystems allow the creation of files with holes in them and that can be accomplished by using a positive "offset" and then writing data at that position. Returns the position on success or -1 on failure.

Reimplemented from input.

◆ setReadBufferSize()

bool filedescriptor::setReadBufferSize ( size_t  size)

If an application performs many small reads, the overhead of the system calls can slow the application down substantially. To address this, the filedescriptor class supports traditional and mmap read buffering.

This method sets the read buffer size to "size" bytes. A size of 0 (or less) means not to buffer reads at all.

Traditional buffering is enabled by default, but mmap buffering can be enabled by calling: setMmapBufferingEnabled(true).

When the underlying file descriptor is storage, such as a file or raw block device, "size" should be a multiple of the block size of the underlying file system or device so that block-aligned reads can be performed.

When the underlying file descriptor is a stream, such as a socket, any "size" can be used.

When traditional buffering is enabled, the class maintains a buffer in user-space and attempts to keep it full. When the buffer is empty, th first read will attempt to read "size" bytes into the buffer but only return the number of bytes specified in the read. Subsequent reads will just return data from the buffer without doing additional system calls unless the buffer is empty.

When using sockets, note that the user-space buffer described above is not the same as the tcp read buffer. The tcp read buffer is analogous, but resides in kernel space, is populated by the read() system call, and is used to minimize network latency.

When mmap buffering is enabled, the underlying storage is memory mapped, and data is read from memory (and thus to the file descriptor) without making system calls.

Note the following...

Mmap buffering can typically only be used with storage file descriptors such as file or raw block devices, and cannot typically be used with streaming file descriptors such as sockets. See setIsStream()/getIsStream().

When mmap buffering is enabled, the read and write buffer sizes must be the same. Calling this method sets both.

On platforms with modern file caching, traditional buffering tends to outperform mmap buffering except in very specific situations such as when O_DIRECT is used to bypass the cache, when using large buffer sizes, or when randomly accessing small parts of large files.

Sometimes a block cannot be memory-mapped. For example:

  • on file systems that don't support mmap
  • if "size" is not a multiple of the underlying file system's block size
  • if the last block of a file is smaller than the block size of the underlying filesystem, and the file is opened read-only In these and other cases, the class will fall back to traditional buffering for any blocks that cannot be mmaped and return to mmap buffering when possible.

Returns true on success and false on failure.

◆ setRetryInterruptedFcntl()

void filedescriptor::setRetryInterruptedFcntl ( bool  retry)

If "retry" is true then a fcntl operation will be automatically retried if it is interrupted by a signal. If "retry" is false then, if a fcntl operation is interrupted by a signal, it will fail and the system error will be set to EINTR.

Defaults to true.

◆ setRetryInterruptedIoctl()

void filedescriptor::setRetryInterruptedIoctl ( bool  retry)

If "retry" is true then an ioctl operation will be automatically retried if it is interrupted by a signal. If "retry" is false then, if an ioctl operation is interrupted by a signal, it will fail and the system error will be set to EINTR.

Defaults to true.

◆ setRetryInterruptedReads()

void filedescriptor::setRetryInterruptedReads ( bool  retry)

If "retry" is true then a read will be automatically retried if it is interrupted by a signal. If "retry" is false then, if a read is interrupted by a signal, it will fail and the system error will be set to EINTR.

Defaults to false.

◆ setRetryInterruptedWaits()

void filedescriptor::setRetryInterruptedWaits ( bool  retry)

If "retry" is true then a wait operation will be automatically retried if it is interrupted by a signal. If "retry" is false then, if a wait operation is interrupted by a signal, it will fail and the system error will be set to EINTR.

Defaults to true.

◆ setRetryInterruptedWrites()

void filedescriptor::setRetryInterruptedWrites ( bool  retry)

If "retry" is true then a write will be automatically retried if it is interrupted by a signal. If "retry" is false then, if a write is interrupted by a signal, it will fail and the system error will be set to EINTR.

Defaults to false.

◆ setSocketLayer()

void filedescriptor::setSocketLayer ( socketlayer layer)

Associates a socketlayer "layer" with the filedescriptor. To remove the current layer, pass in a NULL for "layer".

◆ setSocketReadBufferSize()

bool filedescriptor::setSocketReadBufferSize ( int32_t  size)

Sets the size of the kernel's socket read buffer to "size" bytes. This is only useful for socket file descriptors. Returns true on success and false on failure.

◆ setSocketWriteBufferSize()

bool filedescriptor::setSocketWriteBufferSize ( int32_t  size)

Sets the size of the kernel's socket write buffer to "size" bytes. This is only useful for socket file descriptors. Returns true on success and false on failure.

◆ setTranslateByteOrder()

void filedescriptor::setTranslateByteOrder ( bool  translate)

If "translate" is set true then integers will be translated from native byte order to network byte order during writes and vice-versa during reads.

If "translate" is set false then no translation will be done.

Defaults to false.

◆ setWriteBufferSize()

bool filedescriptor::setWriteBufferSize ( size_t  size)

If an application performs many small writes, the overhead of the system calls can slow the application down substantially. To address this, the filedescriptor class supports traditional and mmap write buffering.

This method sets the write buffer size to "size" bytes. A size of 0 (or less) means not to buffer writes at all.

Traditional buffering is enabled by default, but mmap buffering can be enabled by calling: setMmapBufferingEnabled(true).

When the underlying file descriptor is storage, such as a file or raw block device, "size" should be a multiple of the block size of the underlying file system or device so that block-aligned writes can be performed.

When the underlying file descriptor is a stream, such as a socket, any "size" can be used.

When traditional buffering is enabled, data passed in to any of the write() methods is buffered in user-space, and system calls are only made when the buffer is full or when it's flushed manually. Note that this also means that no data is actually written to the file descriptor until the buffer is full or until it's flushed manually.

When using sockets, note that the user-space buffer described above is not the same as the tcp write buffer. The tcp write buffer is analogous, but resides in kernel space, is populated by the write() system call, and is used to minimize network latency.

When mmap buffering is enabled, the underlying storage is memory mapped, and data is written to memory (and thus to the file descriptor) without making system calls.

Note the following...

Mmap buffering can typically only be used with storage file descriptors such as file or raw block devices, and cannot typically be used with streaming file descriptors such as sockets. See setIsStream()/getIsStream().

When mmap buffering is enabled, the read and write buffer sizes must be the same. Calling this method sets both.

On platforms with modern file caching, traditional buffering tends to outperform mmap buffering except in very specific situations such as when O_DIRECT is used to bypass the cache, when using large buffer sizes, or when randomly accessing small parts of large files.

Sometimes a block cannot be memory-mapped. For example:

  • on file systems that don't support mmap
  • if "size" is not a multiple of the underlying file system's block size In these and other cases, the class will fall back to traditional buffering for any blocks that cannot be mmaped and return to mmap buffering when possible.

Returns true on success and false on failure.

◆ supportsBlockingAndNonBlockingModes()

virtual bool filedescriptor::supportsBlockingAndNonBlockingModes ( )
virtual

Returns true if the system supports blocking/nonblocking modes and false otherwise.

Reimplemented in socketserver, and socketclient.

◆ supportsPassAndReceiveFileDescriptor()

static bool filedescriptor::supportsPassAndReceiveFileDescriptor ( )
static

Returns true if the platform supports passing and receiving file descriptors or false otherwise.

◆ supportsPassAndReceiveSocket()

static bool filedescriptor::supportsPassAndReceiveSocket ( )
static

Returns true if the platform supports passing and receiving sockets or false otherwise.

◆ waitForNonBlockingRead()

int32_t filedescriptor::waitForNonBlockingRead ( int32_t  sec,
int32_t  usec 
)

Causes the application to wait until a read() will proceed without blocking or until "sec" seconds and "usec" microseconds have elapsed.

Entering -1 for either parameter causes the method to wait indefinitely.

Entering 0 for both parameters causes the method to fall through immediately unless a data is immediately available.

Returns RESULT_ERROR on error, RESULT_TIMEOUT on timeout and otherwise returns the number of file descriptors that are ready to be read from.

This will usually be 1, indicating that the file descriptor represented by the class is ready to be read from.

◆ waitForNonBlockingWrite()

int32_t filedescriptor::waitForNonBlockingWrite ( int32_t  sec,
int32_t  usec 
)

Causes the application to wait until a write() will proceed without blocking or until "sec" seconds and "usec" microseconds have elapsed.

Entering -1 for either parameter causes the method to wait indefinitely.

Entering 0 for both parameters causes the method to fall through immediately unless a data is immediately available.

Returns RESULT_ERROR on error, RESULT_TIMEOUT on timeout and otherwise returns the number of file descriptors that are ready to be written to.

This will usually be 1, indicating that the file descriptor represented by the class is ready to be written to.

◆ write() [1/38]

ssize_t filedescriptor::write ( bool  value)
inline

Writes "value" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

◆ write() [2/38]

ssize_t filedescriptor::write ( bool  value,
int32_t  sec,
int32_t  usec 
)
inline

Writes "value" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

◆ write() [3/38]

ssize_t filedescriptor::write ( byte_t  character)
inlinevirtual

Writes "character" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [4/38]

ssize_t filedescriptor::write ( byte_t  character,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "character" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [5/38]

ssize_t filedescriptor::write ( char  character)
inlinevirtual

Writes "character" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [6/38]

ssize_t filedescriptor::write ( char  character,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "character" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [7/38]

ssize_t filedescriptor::write ( const byte_t *  string)
inline

Writes NULL-terminated "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

◆ write() [8/38]

ssize_t filedescriptor::write ( const byte_t *  string,
int32_t  sec,
int32_t  usec 
)
inline

Writes NULL-terminated "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

◆ write() [9/38]

ssize_t filedescriptor::write ( const byte_t *  string,
size_t  size 
)
inlinevirtual

Writes "size" bytes of "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [10/38]

ssize_t filedescriptor::write ( const byte_t *  string,
size_t  size,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "size" bytes of "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Reimplemented from output.

◆ write() [11/38]

ssize_t filedescriptor::write ( const char *  string)
inlinevirtual

Writes NULL-terminated "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [12/38]

ssize_t filedescriptor::write ( const char *  string,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes NULL-terminated "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [13/38]

ssize_t filedescriptor::write ( const char *  string,
size_t  length 
)
inlinevirtual

Writes "length" characters of "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Implements output.

◆ write() [14/38]

ssize_t filedescriptor::write ( const char *  string,
size_t  length,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "length" characters of "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Reimplemented from output.

◆ write() [15/38]

ssize_t filedescriptor::write ( const void *  buffer,
size_t  size 
)
inline

Writes "size" bytes of "buffer" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

◆ write() [16/38]

ssize_t filedescriptor::write ( const void *  buffer,
size_t  size,
int32_t  sec,
int32_t  usec 
)
inline

Writes "size" bytes of "buffer" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

◆ write() [17/38]

ssize_t filedescriptor::write ( const wchar_t *  string)
inlinevirtual

Writes NULL-terminated "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [18/38]

ssize_t filedescriptor::write ( const wchar_t *  string,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes NULL-terminated "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [19/38]

ssize_t filedescriptor::write ( const wchar_t *  string,
size_t  length 
)
inlinevirtual

Writes "length" characters of "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Implements output.

◆ write() [20/38]

ssize_t filedescriptor::write ( const wchar_t *  string,
size_t  length,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "length" characters of "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Reimplemented from output.

◆ write() [21/38]

ssize_t filedescriptor::write ( double  number)
inlinevirtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [22/38]

ssize_t filedescriptor::write ( double  number,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [23/38]

ssize_t filedescriptor::write ( float  number)
inlinevirtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [24/38]

ssize_t filedescriptor::write ( float  number,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [25/38]

ssize_t filedescriptor::write ( int16_t  number)
virtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [26/38]

ssize_t filedescriptor::write ( int16_t  number,
int32_t  sec,
int32_t  usec 
)
virtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [27/38]

ssize_t filedescriptor::write ( int32_t  number)
virtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [28/38]

ssize_t filedescriptor::write ( int32_t  number,
int32_t  sec,
int32_t  usec 
)
virtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [29/38]

ssize_t filedescriptor::write ( int64_t  number)
virtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [30/38]

ssize_t filedescriptor::write ( int64_t  number,
int32_t  sec,
int32_t  usec 
)
virtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [31/38]

ssize_t filedescriptor::write ( uint16_t  number)
virtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [32/38]

ssize_t filedescriptor::write ( uint16_t  number,
int32_t  sec,
int32_t  usec 
)
virtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [33/38]

ssize_t filedescriptor::write ( uint32_t  number)
virtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [34/38]

ssize_t filedescriptor::write ( uint32_t  number,
int32_t  sec,
int32_t  usec 
)
virtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [35/38]

ssize_t filedescriptor::write ( uint64_t  number)
virtual

Writes "number" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [36/38]

ssize_t filedescriptor::write ( uint64_t  number,
int32_t  sec,
int32_t  usec 
)
virtual

Writes "number" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ write() [37/38]

ssize_t filedescriptor::write ( wchar_t  character)
inlinevirtual

Writes "character" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [38/38]

ssize_t filedescriptor::write ( wchar_t  character,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "character" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ writeUcs2() [1/6]

ssize_t filedescriptor::writeUcs2 ( const ucs2_t *  string)
inlinevirtual

Writes NULL-terminated "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ writeUcs2() [2/6]

ssize_t filedescriptor::writeUcs2 ( const ucs2_t *  string,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes NULL-terminated "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.

◆ writeUcs2() [3/6]

ssize_t filedescriptor::writeUcs2 ( const ucs2_t *  string,
size_t  length 
)
inlinevirtual

Writes "length" characters of "string" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Implements output.

◆ writeUcs2() [4/6]

ssize_t filedescriptor::writeUcs2 ( const ucs2_t *  string,
size_t  length,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "length" characters of "string" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Reimplemented from output.

◆ writeUcs2() [5/6]

ssize_t filedescriptor::writeUcs2 ( ucs2_t  character)
inlinevirtual

Writes "character" to the file descriptor. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ writeUcs2() [6/6]

ssize_t filedescriptor::writeUcs2 ( ucs2_t  character,
int32_t  sec,
int32_t  usec 
)
inlinevirtual

Writes "character" to the file descriptor with a timeout of "sec" seconds and "usec" microseconds. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred or RESULT_TIMEOUT if a timeout occurred.

Reimplemented from output.