reSIProcate/rutil  9694
Public Member Functions | Public Attributes
resip::FdSet Class Reference

Object-oriented wrapper for your platform's file-descriptor set. More...

#include <Socket.hxx>

List of all members.

Public Member Functions

 FdSet ()
int select (struct timeval &tv)
int selectMilliSeconds (unsigned long ms)
bool readyToRead (Socket fd)
bool readyToWrite (Socket fd)
bool hasException (Socket fd)
void setRead (Socket fd)
void setWrite (Socket fd)
void setExcept (Socket fd)
void clear (Socket fd)
void reset ()

Public Attributes

fd_set read
fd_set write
fd_set except
int size
int numReady

Detailed Description

Object-oriented wrapper for your platform's file-descriptor set.

Definition at line 121 of file Socket.hxx.


Constructor & Destructor Documentation

resip::FdSet::FdSet ( ) [inline]

Definition at line 124 of file Socket.hxx.

References except, read, and write.

           : size(0), numReady(0)
   {
      FD_ZERO(&read);
      FD_ZERO(&write);
      FD_ZERO(&except);
   }

Member Function Documentation

void resip::FdSet::clear ( Socket  fd) [inline]

Definition at line 194 of file Socket.hxx.

References except, read, and write.

Referenced by resip::FdPollImplFdSet::killCache().

   {
      FD_CLR(fd, &read);
      FD_CLR(fd, &write);
      FD_CLR(fd, &except);
   }
bool resip::FdSet::hasException ( Socket  fd) [inline]

Definition at line 154 of file Socket.hxx.

References except.

Referenced by resip::FdPollImplFdSet::processFdSet().

   {
      return (FD_ISSET(fd,&except) != 0);
   }
bool resip::FdSet::readyToRead ( Socket  fd) [inline]

Definition at line 144 of file Socket.hxx.

References read.

Referenced by resip::SelectInterruptor::process(), and resip::FdPollImplFdSet::processFdSet().

   {
      return (FD_ISSET(fd, &read) != 0);
   }
bool resip::FdSet::readyToWrite ( Socket  fd) [inline]

Definition at line 149 of file Socket.hxx.

References write.

Referenced by resip::FdPollImplFdSet::processFdSet().

   {
      return (FD_ISSET(fd, &write) != 0);
   }
void resip::FdSet::reset ( ) [inline]

Definition at line 201 of file Socket.hxx.

References except, numReady, read, size, and write.

   {
      size = 0;
      numReady = 0;
      FD_ZERO(&read);
      FD_ZERO(&write);
      FD_ZERO(&except);
   }
int resip::FdSet::select ( struct timeval &  tv) [inline]

Definition at line 131 of file Socket.hxx.

References except, numReady, read, size, and write.

Referenced by selectMilliSeconds().

   {
      return numReady = ::select(size, &read, &write, &except, &tv);
   }
int resip::FdSet::selectMilliSeconds ( unsigned long  ms) [inline]

Definition at line 136 of file Socket.hxx.

References select().

Referenced by stunTest(), and resip::FdPollImplFdSet::waitAndProcess().

   {
      struct timeval tv;
      tv.tv_sec = (ms/1000);
      tv.tv_usec = (ms%1000)*1000;
      return select(tv);
   }

Here is the call graph for this function:

void resip::FdSet::setExcept ( Socket  fd) [inline]

Definition at line 182 of file Socket.hxx.

References except, and size.

Referenced by resip::FdPollImplFdSet::addPollItem(), resip::FdPollImplFdSet::buildFdSet(), and resip::FdPollImplFdSet::modPollItem().

   {
#ifndef WIN32 // windows fd are not int's and don't start at 0 - this won't work in windows
      assert( fd < (int)FD_SETSIZE ); // redefinitn FD_SETSIZE will not work 
#else
      assert(except.fd_count < FD_SETSIZE); // Ensure there is room to add new FD
#endif
      FD_SET(fd,&except);
      size = ( int(fd+1) > size) ? int(fd+1) : size;
   }
void resip::FdSet::setRead ( Socket  fd) [inline]

Definition at line 159 of file Socket.hxx.

References read, and size.

Referenced by resip::FdPollImplFdSet::addPollItem(), resip::SelectInterruptor::buildFdSet(), resip::FdPollImplFdSet::buildFdSet(), resip::FdPollImplFdSet::modPollItem(), and stunTest().

   {
      assert( FD_SETSIZE >= 8 );
#ifndef WIN32 // windows fd are not int's and don't start at 0 - this won't work in windows
      assert( fd < (int)FD_SETSIZE ); // redefineing FD_SETSIZE will not work 
#else
      assert(read.fd_count < FD_SETSIZE); // Ensure there is room to add new FD
#endif
      FD_SET(fd, &read);
      size = ( int(fd+1) > size) ? int(fd+1) : size;
   }
void resip::FdSet::setWrite ( Socket  fd) [inline]

Definition at line 171 of file Socket.hxx.

References size, and write.

Referenced by resip::FdPollImplFdSet::addPollItem(), resip::FdPollImplFdSet::buildFdSet(), and resip::FdPollImplFdSet::modPollItem().

   {
#ifndef WIN32 // windows fd are not int's and don't start at 0 - this won't work in windows
      assert( fd < (int)FD_SETSIZE ); // redefinitn FD_SETSIZE will not work 
#else
      assert(write.fd_count < FD_SETSIZE); // Ensure there is room to add new FD
#endif
      FD_SET(fd, &write);
      size = ( int(fd+1) > size) ? int(fd+1) : size;
   }

Member Data Documentation

Definition at line 213 of file Socket.hxx.

Referenced by clear(), FdSet(), hasException(), reset(), select(), and setExcept().

Definition at line 215 of file Socket.hxx.

Referenced by reset(), and select().


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