00001
00002 Copyright (c) 2001, Lee Patterson & Ant Works Software
00003 http://ssobjects.sourceforge.net
00004
00005 filename : servermanager.h
00006 author : Lee Patterson (lee@antws.com)
00007 *********************************************************************/
00008
00009 #ifndef SERVERMANAGER_H
00010 #define SERVERMANAGER_H
00011
00012 #include "ssobjects.h"
00013 #include "threadutils.h"
00014 #include "simpleserver.h"
00015 #include "linkedlist.h"
00016 #include "simpletime.h"
00017 #include "SimpleDate.h"
00018
00019 #ifdef _WIN32
00020 # include <time.h>
00021 #else
00022 # include <sys/time.h>
00023 # include <unistd.h>
00024 #endif
00025
00026 namespace ssobjects
00027 {
00028
00029 class ServerManager : public ThreadHandler
00030 {
00031 public:
00032 enum {MIN_FREQ=10};
00033 protected:
00034 SocketInstance m_sListen;
00035 SockAddr m_saServer;
00036 LinkedList<SimpleServer> m_listSimpleServers;
00037 unsigned32 m_nIdleFrequency;
00038 unsigned32 m_nMaxConnections;
00039 bool m_bUsingThread;
00040 bool m_bPause;
00041 CSimpleTime m_serverStartTime;
00042 CSimpleDate m_serverStartDate;
00043
00044 public:
00045 ServerManager(
00046 const SockAddr& saBind,
00047 const unsigned32 nFreq,
00048 const unsigned32 nMaxConnections,
00049 const bool bUseThread);
00050 virtual ~ServerManager();
00051
00052 void startServer();
00053 bool canBind();
00054 virtual threadReturn ThreadHandlerProc(void);
00055 void acceptConnection(SocketInstance& sListen);
00056
00057
00058 virtual SimpleServer* createServerInstance(
00059 ServerSocket* const psocket,
00060 const SockAddr& saClient,
00061 const unsigned32 nFreq) = 0;
00062
00063 };
00064
00065 };
00066
00067 #endif
00068