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>

Classes

class  EventInfo
 

Public Member Functions

 UT_NetFDSet (bool fast=false, UT_NetFDMode mode=UT_NetFDMode::NETFD_DEFAULT_MODE)
 
 ~UT_NetFDSet ()
 
bool add (int fd, UT_NetFDEvent event)
 
bool add (int fd, const UT_SmallArray< UT_NetFDEvent > &events)
 
bool modify (int fd, const UT_SmallArray< UT_NetFDEvent > &events)
 Modify a file descriptor flags. More...
 
void remove (int fd)
 Remove a file descriptor from the set. More...
 
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) const
 
bool isEmpty () const
 Returns true if the set contains no file descriptors. More...
 
bool isActive (int fd, UT_NetFDEvent event) const
 
bool getInfoWithFD (int fd, EventInfo &info) const
 
bool getAnyEvents (UT_Array< EventInfo > &events, int timeout_ms) const
 
void setMode (UT_NetFDMode mode)
 
SYS_NO_DISCARD_RESULT UT_NetFDMode mode () 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.

Examples:
mocapstream/MocapStreamRokokoHDK.C.

Definition at line 51 of file UT_NetFDSet.h.

Constructor & Destructor Documentation

UT_NetFDSet::UT_NetFDSet ( bool  fast = false,
UT_NetFDMode  mode = UT_NetFDMode::NETFD_DEFAULT_MODE 
)

Constructor and desctructor.

Parameters
fastThis informs the fd set to use the performant variant for the platform. This is currently only support on some platforms.
modeThe mode to run the fd set in.
UT_NetFDSet::~UT_NetFDSet ( )

Member Function Documentation

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

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

Examples:
mocapstream/MocapStreamRokokoHDK.C.
bool UT_NetFDSet::add ( int  fd,
const UT_SmallArray< UT_NetFDEvent > &  events 
)

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

int UT_NetFDSet::checkEvents ( int  timeout_ms) 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.
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.
Examples:
mocapstream/MocapStreamRokokoHDK.C.
bool UT_NetFDSet::contains ( int  fd) const

Test whether a file descriptor is in the set.

bool UT_NetFDSet::getAnyEvents ( UT_Array< EventInfo > &  events,
int  timeout_ms 
) const

Get all events current events in the set. This will wait up to timeout_ms before returning.

Parameters
eventsThe list of all current events in the set. The size of the array is 0..number of fd in set.
timeout_msThe maximum amount of time to wait before givin up. The timeout is in ms.
Returns
True if events has any events in the list.
bool UT_NetFDSet::getInfoWithFD ( int  fd,
EventInfo info 
) const

Get all IO activity from an fd. Returns false if something has gone wrong.

Parameters
fdThis is the file descriptor to get the io information for.
infoThis is the information about a IO activity from the file descriptor provided.
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.

SYS_NO_DISCARD_RESULT UT_NetFDMode UT_NetFDSet::mode ( ) const
inline

Definition at line 142 of file UT_NetFDSet.h.

bool UT_NetFDSet::modify ( int  fd,
const UT_SmallArray< UT_NetFDEvent > &  events 
)

Modify a file descriptor flags.

void UT_NetFDSet::remove ( int  fd)

Remove a file descriptor from the set.

void UT_NetFDSet::removeAll ( )

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

void UT_NetFDSet::setMode ( UT_NetFDMode  mode)
inline

In some cases the mode wont be decided until after the fd set is created. The mode CANNOT be changed while the fdset has fd in it!

Parameters
modeThe mode to run the fd set in.

Definition at line 141 of file UT_NetFDSet.h.

Member Data Documentation

const int UT_NetFDSet::INDEFINITE_WAIT
static

Constants denoting special wait times for checkEvents()

Definition at line 110 of file UT_NetFDSet.h.

const int UT_NetFDSet::NO_WAIT
static

Definition at line 111 of file UT_NetFDSet.h.


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