00001 /* 00002 mySocket, SocketHandler 00003 Copyright (C) 2006 Kornel Csernai <csko@csko.hu> 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 #ifndef SOCKETHANDLER_H 00020 #define SOCKETHANDLER_H 00021 00022 #include <Socket.h> 00023 #include <DoubleLinkedList.h> 00024 #include <RealSocket.h> 00025 #include <Singleton.h> 00026 00027 00028 // Exception class 00029 class SocketHandlerException { 00030 00031 private: 00032 int i; 00033 public: 00034 SocketHandlerException(int _i){ 00035 00036 i = _i; 00037 00038 } 00039 00040 }; 00041 00042 // SocketHandler 00043 class SocketHandler : public Singleton<SocketHandler> { 00044 00045 friend class ListenServer; 00046 friend class IncomingSocket; 00047 00048 public: 00049 00050 SocketHandler(); 00051 ~SocketHandler(); 00052 void Handle(); 00053 bool HaveSockets(); 00054 void Add(Socket* sock); 00055 void Remove(Socket* sock); 00056 00057 00058 private: 00059 00060 struct timeval tv; 00061 00062 DoubleLinkedList<RealSocket*>* l_write; 00063 DoubleLinkedList<Socket*>* l_read; 00064 00065 int socknum; 00066 socket_t maxFD; 00067 00068 }; 00069 00070 #endif