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

OSGSocket.h

Go to the documentation of this file.
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 #ifndef _SOCKET_H_
00040 #define _SOCKET_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include "OSGBase.h"
00046 #include "OSGSocketException.h"
00047 #include "OSGSocketAddress.h"
00048 
00049 OSG_BEGIN_NAMESPACE
00050 
00051 class NetworkMessage;
00052 
00053 class OSG_BASE_DLLMAPPING Socket
00054 {
00055     /*==========================  PUBLIC  =================================*/
00056   public:
00057     /*---------------------------------------------------------------------*/
00061     Socket(void);
00062     Socket(const Socket &source);
00063 
00065     /*---------------------------------------------------------------------*/
00069     virtual ~Socket();
00070 
00072     /*---------------------------------------------------------------------*/
00076     virtual void open   (      void                       )=0;
00077     virtual void close  (      void                       )=0;
00078             void bind   (const SocketAddress &address=
00079                          SocketAddress(SocketAddress::ANY));
00080             void listen (      int maxPending=10          );
00081             void connect(const SocketAddress &address     );
00082 
00084     /*---------------------------------------------------------------------*/
00088     int recv         (      void           *buf,int size);
00089     int recvAvailable(      void           *buf,int size);
00090     int recv         (      NetworkMessage &msg         );
00091     int peek         (      void           *buf,int size);
00092     int send         (const void           *buf,int size);
00093     int send         (      NetworkMessage &msg         );
00094 
00096     /*---------------------------------------------------------------------*/
00100     void          setReusePort      (bool   value   );
00101     void          setBlocking       (bool   value   );
00102     SocketAddress getAddress        (void           );
00103     void          setReadBufferSize (int    size    );
00104     void          setWriteBufferSize(int    size    );
00105     int           getReadBufferSize (void           );
00106     int           getWriteBufferSize(void           );
00107     int           getAvailable      (void           );
00108     bool          waitReadable      (double duration);
00109     bool          waitWritable      (double duration);
00110 
00112     /*---------------------------------------------------------------------*/
00116     const Socket & operator =(const Socket &source);
00117 
00119     /*---------------------------------------------------------------------*/
00123     static int         getError       (void);
00124     static int         getHostError   (void);
00125     static std::string getErrorStr    (void);
00126     static std::string getHostErrorStr(void);
00127 
00130     /*==========================  PROTECTED ===============================*/
00131   protected:
00132 
00136 #if defined WIN32
00137     typedef char FAR  SocketOptT;
00138 #else
00139     typedef void      SocketOptT;
00140 #endif
00141 
00145 #if defined __linux
00146     typedef socklen_t SocketLenT;
00147 #else
00148     typedef int       SocketLenT;
00149 #endif
00150 
00151     /*---------------------------------------------------------------------*/
00155     int _sd;
00156 
00158     /*==========================  PRIVATE =================================*/
00159   private:
00160 
00161     friend class SocketSelection;
00162 
00163     /*---------------------------------------------------------------------*/
00167     static int  initialized;
00168 
00170 };
00171 
00172 OSG_END_NAMESPACE
00173 
00174 #define OSG_SOCKET_HEADER_CVSID "@(#)$Id: $"
00175 
00176 #endif

Generated on Thu Aug 25 04:10:26 2005 for OpenSG by  doxygen 1.4.3