1 /******************************************************************************** 2 * Nepenthes 3 * - finest collection - 4 * 5 * 6 * 7 * Copyright (C) 2005 Paul Baecher & Markus Koetter 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; either version 2 12 * of the License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 * 23 * 24 * contact nepenthesdev@users.sourceforge.net 25 * 26 *******************************************************************************/ 27 28 /* $Id: SocketManager.hpp 605 2006-08-07 23:13:31Z common $ */ 29 30 #ifndef HAVE_SOCKETMANAGER_HPP 31 #define HAVE_SOCKETMANAGER_HPP 32 33 #include <list> 34 #include <stdint.h> 35 #include <ctime> 36 37 #include "Manager.hpp" 38 39 using namespace std; 40 41 namespace nepenthes 42 { 43 class Socket; 44 class POLLSocket; 45 class Nepenthes; 46 class DialogueFactory; 47 class Dialogue; 48 49 /** 50 * the SocketManager keeps his Socket 's working. 51 * he cares about them like a mum, if they are dead, he removes them, if they establish, he polls them 52 * if you want a new connection, the SocketManager will set one up 53 */ 54 class SocketManager : public Manager 55 { 56 public: 57 SocketManager(Nepenthes *pNepethes); 58 virtual ~SocketManager(); 59 virtual Socket *bindTCPSocket(uint32_t localHost, uint16_t Port,time_t bindtimeout,time_t accepttimeout); 60 virtual Socket *bindTCPSocket(uint32_t localHost, uint16_t Port,time_t bindtimeout,time_t accepttimeout, DialogueFactory *dialoguefactory); 61 virtual Socket *bindTCPSocket(uint32_t localHost, uint16_t Port,time_t bindtimeout,time_t accepttimeout, char *dialoguefactoryname); 62 63 virtual Socket *bindUDPSocket(uint32_t localhost, uint16_t port,time_t bindtimeout,time_t accepttimeout, DialogueFactory *dialoguefactory); 64 65 virtual Socket *openFILESocket(char *filepath, int32_t flags); 66 virtual Socket *connectUDPHost(uint32_t localHost, uint32_t remotehost, uint16_t remoteport,time_t connecttimeout); 67 virtual Socket *connectTCPHost(uint32_t localHost, uint32_t remotehost, uint16_t remoteport,time_t connecttimeout); 68 virtual Socket *connectTCPHost(uint32_t localHost, uint32_t remotehost, uint16_t localport, uint16_t remoteport,time_t connecttimeout); 69 70 virtual Socket *addPOLLSocket(POLLSocket *sock); 71 virtual bool removePOLLSocket(POLLSocket *sock); 72 73 bool doLoop(uint32_t polltimeout); 74 75 bool Init(); 76 bool Exit(); 77 void doList(); 78 79 private: 80 list<Socket *> m_Sockets; 81 bool m_UseRawSockets; 82 uint32_t m_BindAddress; 83 }; 84 85 } 86 87 #endif 88 89