// // Server // /* prevent multiple inclusions */ #ifndef __Server__ #define __Server__ /* includes *****************************************************************/ #include "Socket.h" /* defines ******************************************************************/ /* macros *******************************************************************/ /* structs & typedefs *******************************************************/ /* c class definitions ******************************************************/ class Server { // public data public: protected: // socket int m_nfds; /* number of descriptors */ fd_set m_rfds; /* set of open sockets */ // select fd_set m_sfds; struct timeval m_timeout; struct timeval m_seltime; bool m_client_to; // reset timeout on client // private data private: // static data // public methods public: // constructors Server(); // destructor virtual ~Server(); // public methods // control void SetTimeout(time_t to); void SetTimeout(timeval &tv); void ResetTimeout(void); void ResetClientTimeout(void) {if(m_client_to)ResetTimeout();}; void ResetServerTimeout(void) {ResetTimeout();}; void SetClientTimeout(bool ct) {m_client_to=ct;}; // select void AddFd(int sock) {if(sock>=0)m_nfds=fd_add(sock,&m_rfds,m_nfds);}; void DelFd(int sock) {if(sock>=0)FD_CLR(sock,&m_rfds);}; bool IsSet(int sock) {if(sock>=0)return FD_ISSET(sock,&m_sfds);return 0;}; int Select( void ); // service int ServiceUri( const char *uri ); // virtual functions virtual int Service( const char *host, const char *service=NULL ) {return -1;}; virtual int Listen( void ) {return 0;}; virtual int ServerTimeout(void) {return 0;}; virtual int ServerSocket(void) {return 0;}; // other socket // exceptions // static methods // private methods private: }; #endif