Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

RefCountedSocket.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef MN_RTP_REF_COUNTED_SOCKET_H 00025 #define MN_RTP_REF_COUNTED_SOCKET_H 00026 00027 00028 #include <assert.h> 00029 #include <stdio.h> 00030 #include <sys/types.h> 00031 00032 #include "MNArrayList.h" 00033 #include "DatagramSocket.h" 00034 #include "MNMutex.h" 00035 #include "MNValid.h" 00036 00037 class RefCountedSocket; 00038 class RefCountedSocketFactory; 00039 class RefCountingSocket; 00040 class MNRope; 00041 00042 /**********************************************************************/ 00043 /* RefCountedSocket */ 00044 /**********************************************************************/ 00045 00073 class RefCountedSocket : public DatagramSocket 00074 { 00075 DECLARE_VALID 00076 00077 private: 00078 struct MulticastInfo 00079 { 00082 MNUDPServerSocket::Interfaces* _iface; 00083 00088 int _port; 00089 00092 char* _addr; 00093 00096 bool _joined; 00097 00100 MulticastInfo(); 00101 00102 ~MulticastInfo(); 00103 }; 00104 00106 size_t _refCtr; 00107 00111 MNArrayList<RefCountingSocket*> _notificationList; 00112 00115 MulticastInfo _mc; 00116 00120 RefCountedSocketFactory* _factory; 00121 00122 private: 00124 RefCountedSocket( const RefCountedSocket& ); 00125 00127 RefCountedSocket& operator=( const RefCountedSocket& ); 00128 00129 public: 00130 RefCountedSocket( RefCountedSocketFactory* factory, 00131 MNSelector& sel, 00132 MNSocket& sock ); 00133 00134 RefCountedSocket( RefCountedSocketFactory* factory, 00135 MNSelector& sel, 00136 int port ); 00137 00149 virtual ~RefCountedSocket( ); 00150 00156 void attach( ); 00157 00160 void detach( ); 00161 00166 void startReading( RefCountingSocket* s, bool sender ); 00167 00171 void stopReading( RefCountingSocket* s ); 00172 00185 bool release( RefCountingSocket* s ); 00186 00190 virtual int reader ( struct iovec* iov, 00191 int len, 00192 struct sockaddr_in*& dest ); 00193 00194 virtual int reader ( MNRope*& rope, 00195 struct sockaddr_in*& dest ); 00196 00197 00198 virtual void writer ( ); 00199 00203 virtual void connection_closed( ); 00204 00216 struct ifi_info* get_ifi_info(int family, int doaliases); 00217 00226 bool join_multicast( int port, const char* address ); 00227 00230 bool is_multicast_joined( ) const; 00231 00235 void leaveMulticast( ); 00236 00240 void set_multicast_ttl( int val ); 00241 00245 int get_multicast_ttl( ); 00246 00250 void set_multicast_if( const char* ifname ); 00251 00270 int send( struct iovec* iov, 00271 size_t iov_size, 00272 int target_port, 00273 const char* target_host ); 00274 00286 int send( struct iovec* iov, 00287 size_t iov_size, 00288 const struct sockaddr_in& sock_addr ); 00289 00299 int send( MNRope* rope, 00300 const struct sockaddr_in& sock_addr ); 00301 }; 00302 00303 #endif /* MN_RTP_REF_COUNTED_SOCKET_H */ 00304

Generated on Sun Mar 6 13:35:50 2005 for Komssys by doxygen 1.3.8