00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef FDSET_H
00013 #define FDSET_H
00014
00017 #include <string.h>
00018 #include <sys/time.h>
00019
00020 #if defined(Linux)
00021 # include <sys/types.h>
00022 # include <unistd.h>
00023 #endif
00024
00025 #include <algorithm>
00026 #include <string>
00027 #include <sstream>
00028 #include <iostream>
00029 #include <list>
00030
00031 #include "assa/Logger.h"
00032
00033 namespace ASSA {
00034
00051 class FdSet : public fd_set
00052 {
00053 public:
00056 FdSet ();
00057
00062 bool setFd (handler_t fd_);
00063
00068 bool clear (handler_t fd_);
00069
00074 bool isSet (handler_t fd_);
00075
00078 void sync ();
00079
00082 void reset ();
00083
00087 int numSet ();
00088
00091 void dump ();
00092
00095 std::string dump_c_str ();
00096
00097 private:
00098
00099 #if !defined (WIN32)
00100 typedef std::list<u_int>::iterator ActiveFDs_Iter;
00101
00102 std::list<u_int> m_actfds;
00103 #endif
00104 };
00105
00106
00107
00108
00109 inline FdSet::FdSet () { reset (); }
00110 inline void FdSet::dump () { DL ((REACT, "%s\n", dump_c_str ().c_str ())); }
00111
00112 inline bool FdSet::isSet (handler_t fd_) { return FD_ISSET (fd_, this); }
00113
00114 inline int
00115 FdSet::
00116 numSet ()
00117 {
00118 #if defined (WIN32)
00119 return this->fd_count;
00120 #else
00121 return m_actfds.size ();
00122 #endif
00123 }
00124
00125
00126 }
00127
00128 #endif