00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 00040 #ifndef _POINTSOCKCONNECTION_H_ 00041 #define _POINTSOCKCONNECTION_H_ 00042 #ifdef __sgi 00043 #pragma once 00044 #endif 00045 00046 //--------------------------------------------------------------------------- 00047 // Includes 00048 //--------------------------------------------------------------------------- 00049 00050 #include <string> 00051 #include <OSGBase.h> 00052 #include <OSGBaseTypes.h> 00053 #include <OSGPointConnection.h> 00054 #include <OSGTime.h> 00055 #include <OSGStreamSocket.h> 00056 00057 OSG_BEGIN_NAMESPACE 00058 00059 class OSG_BASE_DLLMAPPING PointSockConnection : public PointConnection 00060 { 00061 /*========================== PUBLIC =================================*/ 00062 public: 00063 00064 /*---------------------------------------------------------------------*/ 00068 PointSockConnection ( void ); 00069 virtual ~PointSockConnection ( void ); 00070 00072 /*---------------------------------------------------------------------*/ 00076 virtual const ConnectionType *getType (void); 00077 00079 /*---------------------------------------------------------------------*/ 00083 virtual Channel connectPoint(const std::string &address, 00084 Time timeout=-1 ); 00085 virtual Channel connectGroup(const std::string &address, 00086 Time timeout=-1 ); 00087 virtual void disconnect ( void ); 00088 virtual Channel acceptGroup ( Time timeout=-1 ); 00089 virtual Channel acceptPoint ( Time timeout=-1 ); 00090 virtual std::string bind (const std::string &interf ); 00091 00093 /*---------------------------------------------------------------------*/ 00097 virtual bool wait (Time timeout) throw (ReadError ); 00098 virtual void signal(void ) throw (WriteError); 00099 00101 /*---------------------------------------------------------------------*/ 00105 virtual Channel selectChannel (Time timeout=-1) throw (ReadError); 00106 00108 /*---------------------------------------------------------------------*/ 00112 static PointConnection *create(void); 00113 00116 /*========================= PROTECTED ===============================*/ 00117 protected: 00118 00119 /*---------------------------------------------------------------------*/ 00123 struct SocketBufferHeader { 00124 UInt32 size; 00125 }; 00126 00128 /*---------------------------------------------------------------------*/ 00132 virtual void read (MemoryHandle mem, UInt32 size); 00133 virtual void readBuffer (void); 00134 virtual void write (MemoryHandle mem, UInt32 size); 00135 virtual void writeBuffer (void); 00136 00138 /*---------------------------------------------------------------------*/ 00142 StreamSocket _acceptSocket; 00143 StreamSocket _socket; 00144 std::vector<UInt8> _socketReadBuffer; 00145 std::vector<UInt8> _socketWriteBuffer; 00146 00149 /*========================== PRIVATE ================================*/ 00150 private: 00151 00152 /*---------------------------------------------------------------------*/ 00156 static ConnectionType _type; 00157 00160 typedef PointConnection Inherited; 00161 00162 // prohibit default functions (move to 'public' if you need one) 00163 PointSockConnection(const PointSockConnection &source); 00164 PointSockConnection& operator =(const PointSockConnection &source); 00165 }; 00166 00167 //--------------------------------------------------------------------------- 00168 // Exported Types 00169 //--------------------------------------------------------------------------- 00170 00171 // class pointer 00172 00173 typedef PointSockConnection *PointSockConnectionP; 00174 00175 OSG_END_NAMESPACE 00176 00177 #define OSG_GROUPSOCKCONNECTION_HEADER_CVSID "@(#)$Id: $" 00178 00179 #endif /* _GROUPSOCKCONNECTION_H_ */
1.4.3