Rudiments
Public Member Functions | List of all members
listener Class Reference

Inherits object.

Public Member Functions

 listener ()
 
virtual ~listener ()
 
void addFileDescriptor (filedescriptor *fd)
 
void addReadFileDescriptor (filedescriptor *fd)
 
void addWriteFileDescriptor (filedescriptor *fd)
 
void removeFileDescriptor (filedescriptor *fd)
 
void removeAllFileDescriptors ()
 
int32_t listen ()
 
int32_t listen (int32_t sec, int32_t usec)
 
singlylinkedlist< filedescriptor * > * getReadReadyList ()
 
singlylinkedlist< filedescriptor * > * getWriteReadyList ()
 
void retryInterruptedWaits (bool retry)
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

The listener class listens for activity on a pool of filedescriptors or children of the filedescriptor class.

Constructor & Destructor Documentation

◆ listener()

listener::listener ( )

Creates an instance of the listener class.

◆ ~listener()

virtual listener::~listener ( )
virtual

Deletes this instance of the listener class.

Member Function Documentation

◆ addFileDescriptor()

void listener::addFileDescriptor ( filedescriptor fd)

Adds the specified file descriptor to the pool that the listener is listening on. When listen() is called, it will listen for read or write operations on this file descriptor.

◆ addReadFileDescriptor()

void listener::addReadFileDescriptor ( filedescriptor fd)

Adds the specified file descriptor to the pool that the listener is listening on. When listen() is called, it will only listen for read operations on this file descriptor.

◆ addWriteFileDescriptor()

void listener::addWriteFileDescriptor ( filedescriptor fd)

Adds the specified file descriptor to the pool that the listener is listening on. When listen() is called, it will only listen for write operations on this file descriptor.

◆ getReadReadyList()

singlylinkedlist<filedescriptor *>* listener::getReadReadyList ( )

Returns the list of file descriptors that were ready for read operations after the last call to listen().

◆ getWriteReadyList()

singlylinkedlist<filedescriptor *>* listener::getWriteReadyList ( )

Returns the list of file descriptors that were ready for write operations after the last call to listen().

◆ listen() [1/2]

int32_t listener::listen ( )

Causes the application to wait until a read or write operation will proceed without blocking, as appropriate for each file descriptor added by previous calls.

Returns RESULT_ERROR on error or otherwise returns the number of file descriptors that are ready to be read from or written to.

◆ listen() [2/2]

int32_t listener::listen ( int32_t  sec,
int32_t  usec 
)

Causes the application to wait until a read or write operation will proceed without blocking, as appropriate for each file descriptor added by previous calls, 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, returning RESULT_TIMEOUT unless a write operation will immediately proceed without blocking.

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

◆ removeAllFileDescriptors()

void listener::removeAllFileDescriptors ( )

Removes all file descriptors from the pool.

◆ removeFileDescriptor()

void listener::removeFileDescriptor ( filedescriptor fd)

Removes the specified file descriptor from the pool.

◆ retryInterruptedWaits()

void listener::retryInterruptedWaits ( bool  retry)

If "retry" is true then waits are automatically retried if interrupted by a signal. If "retry" is false then waits are not automatically retried if interrupted by a signel.

Defaults to true.