HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_NetFDSet Class Reference

Abstracts the socket file descriptor set for select() or poll() calls. More...

#include <UT_NetFDSet.h>

Public Member Functions

 UT_NetFDSet ()
 Constructor and desctructor. More...
 
 ~UT_NetFDSet ()
 
void add (int fd, UT_NetFDEvent event)
 
bool contains (int fd) const
 Test whether a file descriptor is in the set. More...
 
void removeAll ()
 Removes all added file descriptors for all events (resets the set). More...
 
int checkEvents (int timeout_ms, bool force_socket=false) const
 
bool isEmpty () const
 Returns true if the set contains no file descriptors. More...
 
bool isActive (int fd, UT_NetFDEvent event) const
 

Static Public Attributes

static const int INDEFINITE_WAIT
 Constants denoting special wait times for checkEvents() More...
 
static const int NO_WAIT
 

Detailed Description

Abstracts the socket file descriptor set for select() or poll() calls.

Definition at line 30 of file UT_NetFDSet.h.

Constructor & Destructor Documentation

UT_NetFDSet::UT_NetFDSet ( )

Constructor and desctructor.

UT_NetFDSet::~UT_NetFDSet ( )

Member Function Documentation

void UT_NetFDSet::add ( int  fd,
UT_NetFDEvent  event 
)

Adds a file descriptor to the set with the intent of monitoring the given IO event.

int UT_NetFDSet::checkEvents ( int  timeout_ms,
bool  force_socket = false 
) const

Checks or waits for the IO events on the file descriptors in the set. Essentially it's a wrapper for select() or poll().

Parameters
timeout_msThe timeout to wait for connection (in miliseconds). If zero, the call does not wait for the events, but instead checks for the current state of the FDs in the set. If negative, the call blocks indefinitely, waiting for the first event. This is equivalent to passing NULL to select() or -1 to poll() as time value.
force_socketOn Windows, indicates to use sockets rather than resorting to pipes.
Returns
The total number of file descriptors on which there was activitiy (events of the registered type), or -1 if error occured. If time limit expires, returns 0.
bool UT_NetFDSet::contains ( int  fd) const

Test whether a file descriptor is in the set.

bool UT_NetFDSet::isActive ( int  fd,
UT_NetFDEvent  event 
) const

Returns true if there was any IO activity of the given type on the given file descriptor.

bool UT_NetFDSet::isEmpty ( ) const

Returns true if the set contains no file descriptors.

void UT_NetFDSet::removeAll ( )

Removes all added file descriptors for all events (resets the set).

Member Data Documentation

const int UT_NetFDSet::INDEFINITE_WAIT
static

Constants denoting special wait times for checkEvents()

Definition at line 65 of file UT_NetFDSet.h.

const int UT_NetFDSet::NO_WAIT
static

Definition at line 66 of file UT_NetFDSet.h.


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