Drizzled Public API Documentation

network_ms.h
00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-05-25
00023  *
00024  * H&G2JCtL
00025  *
00026  * Network interface.
00027  *
00028  */
00029 
00030 #pragma once
00031 #ifndef __NETWORK_MS_H__
00032 #define __NETWORK_MS_H__
00033 
00034 #include "cslib/CSDefs.h"
00035 #include "cslib/CSSocket.h"
00036 #include "cslib/CSThread.h"
00037 #include "connection_handler_ms.h"
00038 
00039 class MSSystemThread : public CSDaemon {
00040 public:
00041   MSSystemThread(time_t wait_time, CSThreadList *list): CSDaemon(wait_time, list) { }
00042 
00043   virtual bool doWork();
00044 };
00045 
00046 class MSNetwork {
00047 public:
00048   static void startUp(int port);
00049   static void shutDown();
00050   static CSSocket *openConnection(MSConnectionHandler *handler);
00051   static void startConnectionHandler();
00052   static void startNetwork();
00053   static bool lockListenerSocket(MSConnectionHandler *handle);
00054   static void unlockListenerSocket();
00055   static CSMutex *getListenerLock() { return &gListenerLock; }
00056   static bool killListener();
00057 
00058 public:
00059   static MSSystemThread   *gSystemThread;
00060   static time_t       gCurrentTime;
00061   static time_t       gLastService;
00062   static CSThreadList     *gHandlerList;
00063   static CSSync       gListenerLock;
00064   static CSSocket       *gListenerSocket;
00065   static MSConnectionHandler  *gListenerThread;
00066   static uint32_t       gWaitingToListen;
00067 
00068 private:
00069   static int          handlerCount;
00070 };
00071 
00072 #endif