00001 /* 00002 ot_lib - Object Type Library 00003 Copyright (C) 2002 Alessandro Bonfanti 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library 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 GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 Alessandro Bonfanti 00020 xjbon@tin.it 00021 */ 00022 00023 00024 class serverTCPSocket; 00025 00026 class clientTCPSession : public ost::TCPSession 00027 { 00028 private: 00029 00030 serverTCPSocket *m_server; 00031 ot_functionManager &m_fm; 00032 00033 void run(void); 00034 void final(void); 00035 00036 public: 00037 00038 clientTCPSession(serverTCPSocket *server,ot_functionManager &fm); 00039 00040 ~clientTCPSession(void); 00041 }; 00042 00043 00044 class acceptTCPSocket; 00045 00046 class serverTCPSocket : public ost::TCPSocket 00047 { 00048 private: 00049 00050 auto_ptr<acceptTCPSocket> m_acceptSocket; 00051 bool m_isOn; 00052 list<pthread_t> m_threads; 00053 ot_functionManager &m_fm; 00054 00055 00056 protected: 00057 00058 bool onAccept(const ost::InetHostAddress &ia, 00059 ost::tpport_t port); 00060 00061 public: 00062 00063 serverTCPSocket(ot_functionManager &fm, 00064 ost::InetAddress &ia, 00065 int port); 00066 00067 ~serverTCPSocket(void); 00068 00069 void addThread(pthread_t t); 00070 void deleteThread(pthread_t t); 00071 00072 int getThreadNum(void) const; 00073 00074 void enable(bool flag); 00075 }; 00076 00077 00078 class acceptTCPSocket : public ost::Thread 00079 { 00080 private: 00081 00082 serverTCPSocket *m_s; 00083 ot_functionManager &m_fm; 00084 00085 void run(void); 00086 00087 public: 00088 00089 acceptTCPSocket(serverTCPSocket *s,ot_functionManager &fm); 00090 ~acceptTCPSocket(void); 00091 };