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 _GROUPSOCKCONNECTION_H_
41 #define _GROUPSOCKCONNECTION_H_
46 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
52 #include "OSGBaseDef.h"
53 #include "OSGBaseTypes.h"
54 #include "OSGGroupConnection.h"
56 #include "OSGStreamSocket.h"
60 class PointSockConnection
;
62 /*! \ingroup GrpBaseNetwork
63 \ingroup GrpBaseNetworkSockets
64 \ingroup GrpLibOSGBase
67 class OSG_BASE_DLLMAPPING GroupSockConnection
: public GroupConnection
69 /*========================== PUBLIC =================================*/
72 /*---------------------------------------------------------------------*/
73 /*! \name Constructors */
76 GroupSockConnection ( void );
77 virtual ~GroupSockConnection ( void );
80 /*---------------------------------------------------------------------*/
81 /*! \name type info */
84 virtual const ConnectionType
*getType (void);
87 /*---------------------------------------------------------------------*/
88 /*! \name connection */
91 virtual Channel
connectPoint(const std::string
&address
,
93 virtual void disconnect ( Channel channel
);
94 virtual Channel
acceptPoint ( Time timeout
=-1 );
95 virtual std::string
bind (const std::string
&interf
);
98 /*---------------------------------------------------------------------*/
102 virtual void setParams(const std::string
¶ms
);
105 /*---------------------------------------------------------------------*/
106 /*! \name channel handling */
109 virtual Channel
selectChannel (Time timeout
=-1) OSG_THROW (ReadError
);
112 /*---------------------------------------------------------------------*/
116 static GroupConnection
*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
);
141 virtual void write (MemoryHandle mem
, UInt32 size
);
142 virtual void writeBuffer (void);
145 /*---------------------------------------------------------------------*/
149 StreamSocket _acceptSocket
;
150 std::vector
<StreamSocket
> _sockets
;
151 std::vector
<SocketAddress
> _remoteAddresses
;
152 ChannelIndex _readIndex
;
153 std::vector
<UInt8
> _socketReadBuffer
;
154 std::vector
<UInt8
> _socketWriteBuffer
;
157 /*---------------------------------------------------------------------*/
158 /*! \name synchronisation */
161 virtual bool wait (Time timeout
) OSG_THROW (ReadError
);
162 virtual void signal(void ) OSG_THROW (WriteError
);
166 /*========================== PRIVATE ================================*/
169 friend class PointSockConnection
;
171 /*---------------------------------------------------------------------*/
172 /*! \name static type */
175 static ConnectionType _type
;
178 /*---------------------------------------------------------------------*/
179 /*! \name internal methods */
182 static bool connectSocket(StreamSocket
&socket
,
184 SocketAddress
&destination
,
186 static bool acceptSocket (StreamSocket
&accept
,
188 SocketAddress
&destination
,
193 typedef GroupConnection Inherited
;
195 // prohibit default functions (move to 'public' if you need one)
196 GroupSockConnection(const GroupSockConnection
&source
);
197 GroupSockConnection
& operator =(const GroupSockConnection
&source
);
200 //---------------------------------------------------------------------------
202 //---------------------------------------------------------------------------
206 typedef GroupSockConnection
*GroupSockConnectionP
;
210 #endif /* _GROUPSOCKCONNECTION_H_ */