/*! \file server.h This is the Server class definition. It implements a common non-blocking select() server. \author Jon A. Lambert \date 02/15/2003 \version 0.10 */ #ifndef SERVER_H #define SERVER_H #include "connection.h" //! ConnList is typedef'd here for ease of changing it later //##ModelId=3ED44BF10181 typedef list<Connection*> ConnList; /*! The Server class defines a singleton representation of a virtual network server. \notes No reason why this should be a singleton as long as different ports are served. \todo - Make Server an abstract class overriding its Run method to illustrate different network designs as well as different types of servers, e.g. httpd, ftpd, instead of telnetd. - Move Execute out of here as it belongs to some Chat engine */ //##ModelId=3ED44BF101B2 class Server { public: //##ModelId=3ED44BF10311 static Server* Instance(); //##ModelId=3ED44BF10313 bool Boot(unsigned short port); //##ModelId=3ED44BF1031C void Run(); //##ModelId=3ED44BF10325 static void Destroy(); private: //##ModelId=3ED44BF10327 Server(); //##ModelId=3ED44BF1032F ~Server(); //##ModelId=3ED44BF10330 Server(const Server&); //##ModelId=3ED44BF1033A Server& operator= (const Server&); //##ModelId=3ED44BF102A6 static Server* sInstance; //!< pointer to the singleton Server instance //##ModelId=3ED44BF102B7 bool mShutdown; //!< flag indicating whether the server is shutting down //##ModelId=3ED44BF102C1 fd_set mInputFDs; //!< array of input sockets that select will test //##ModelId=3ED44BF102CB fd_set mOutputFDs; //!< array of output sockets that select will test //##ModelId=3ED44BF102DF SOCKET mAcceptor; //!< socket that the Server listens to for incoming connections //##ModelId=3ED44BF102E9 struct sockaddr_in mTo; //!< network address of the server listening port //##ModelId=3ED44BF102FE ConnList mUsers; //!< the list of Connections managed by the Server //##ModelId=3ED44BF10344 Connection* AcceptConnection(); //##ModelId=3ED44BF1034D void InitFDs (); //##ModelId=3ED44BF1034E void Execute(); //##ModelId=3ED44BF10357 void ShutdownServer(); }; #endif // SERVER_H