1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
40 #ifndef _POINTMCASTCONNECTION_H_
41 #define _POINTMCASTCONNECTION_H_
46 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
53 #include "OSGBaseDef.h"
54 #include "OSGBaseTypes.h"
55 #include "OSGPointSockConnection.h"
57 #include "OSGDgramSocket.h"
59 #include "OSGDgramQueue.h"
63 /*! \ingroup GrpBaseNetwork
64 \ingroup GrpBaseNetworkSockets
65 \ingroup GrpLibOSGBase
68 class OSG_BASE_DLLMAPPING PointMCastConnection
: public PointSockConnection
70 /*========================== PUBLIC =================================*/
73 /*---------------------------------------------------------------------*/
74 /*! \name Constructors */
77 PointMCastConnection ( void );
78 virtual ~PointMCastConnection ( void );
81 /*---------------------------------------------------------------------*/
82 /*! \name type info */
85 virtual const ConnectionType
*getType (void);
88 /*---------------------------------------------------------------------*/
89 /*! \name connection */
92 virtual Channel
connectGroup(const std::string
&address
,
94 virtual void disconnect ( void );
95 virtual Channel
acceptGroup ( Time timeout
=-1 );
98 /*---------------------------------------------------------------------*/
99 /*! \name synchronisation */
102 virtual bool wait (Time timeout
) OSG_THROW (ReadError
);
105 /*---------------------------------------------------------------------*/
106 /*! \name channel handling */
109 virtual Channel
selectChannel (Time timeout
=-1) OSG_THROW (ReadError
);
112 /*---------------------------------------------------------------------*/
116 static PointConnection
*create(void);
120 /*========================= PROTECTED ===============================*/
123 /*---------------------------------------------------------------------*/
130 struct SocketBufferHeader
{
135 /*---------------------------------------------------------------------*/
136 /*! \name IO Implementation */
139 virtual void read (MemoryHandle mem
, UInt32 size
);
140 virtual void readBuffer (void) OSG_THROW (ReadError
);
143 /*---------------------------------------------------------------------*/
147 DgramSocket _mcastSocket
;
148 DgramSocket _responseSocket
;
149 BaseThreadRefPtr _recvQueueThread
;
150 bool _recvQueueThreadRunning
;
151 bool _recvQueueThreadStop
;
153 SocketAddress _mcastAddress
;
157 SocketAddress _sender
;
158 SocketAddress _ackDestination
;
160 UInt32 _lastDgramPos
;
162 std::map
<SocketAddress
,UInt16
> _combineAck
;
167 /*========================== PRIVATE ================================*/
170 /*---------------------------------------------------------------------*/
171 /*! \name private helpers */
174 bool recvNextDgram (Dgram
*dgram
);
175 void combineAck (Dgram
*dgram
,SocketAddress from
);
176 static void recvQueueThread( void *arg
);
177 bool recvQueue ( void );
178 void initialize ( void );
181 /*---------------------------------------------------------------------*/
182 /*! \name static type */
185 static ConnectionType _type
;
189 typedef PointSockConnection Inherited
;
191 // prohibit default functions (move to 'public' if you need one)
192 PointMCastConnection(const PointMCastConnection
&source
);
193 PointMCastConnection
& operator =(const PointMCastConnection
&source
);
196 //---------------------------------------------------------------------------
198 //---------------------------------------------------------------------------
202 typedef PointMCastConnection
*PointMCastConnectionP
;
206 #endif /* _GROUPMCASTCONNECTION_H_ */