fixed: gcc8 compile issues
[opensg.git] / Source / Base / Network / Socket / OSGSocket.h
blobf94bc778dbe0680cd85745df0140d7230a735edc
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _SOCKET_H_
40 #define _SOCKET_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGBaseDef.h"
46 #include "OSGSocketException.h"
47 #include "OSGSocketAddress.h"
49 OSG_BEGIN_NAMESPACE
51 class NetworkMessage;
53 /*! \ingroup GrpBaseNetwork
54 \ingroup GrpBaseNetworkSockets
55 \ingroup GrpLibOSGBase
58 class OSG_BASE_DLLMAPPING Socket
60 /*========================== PUBLIC =================================*/
61 public:
62 /*---------------------------------------------------------------------*/
63 /*! \name Constructors */
64 /*! \{ */
66 Socket(void);
67 Socket(const Socket &source);
69 /*! \} */
70 /*---------------------------------------------------------------------*/
71 /*! \name Destructor */
72 /*! \{ */
74 virtual ~Socket();
76 /*! \} */
77 /*---------------------------------------------------------------------*/
78 /*! \name open, close, connect */
79 /*! \{ */
81 virtual void open ( void ) = 0;
82 virtual void close ( void ) = 0;
83 void bind (const SocketAddress &address=
84 SocketAddress(SocketAddress::ANY));
85 void listen ( int maxPending=10 );
86 void connect(const SocketAddress &address );
88 /*! \} */
89 /*---------------------------------------------------------------------*/
90 /*! \name read, write */
91 /*! \{ */
93 int recv ( void *buf,int size);
94 int recvAvailable( void *buf,int size);
95 int recv ( NetworkMessage &msg );
96 int peek ( void *buf,int size);
97 int send (const void *buf,int size);
98 int send ( NetworkMessage &msg );
100 /*! \} */
101 /*---------------------------------------------------------------------*/
102 /*! \name state access */
103 /*! \{ */
105 void setReusePort (bool value );
106 void setBlocking (bool value );
107 SocketAddress getAddress (void );
108 void setReadBufferSize (int size );
109 void setWriteBufferSize(int size );
110 int getReadBufferSize (void );
111 int getWriteBufferSize(void );
112 int getAvailable (void );
113 bool waitReadable (double duration);
114 bool waitWritable (double duration);
116 /*! \} */
117 /*---------------------------------------------------------------------*/
118 /*! \name Assignment */
119 /*! \{ */
121 const Socket & operator =(const Socket &source);
123 /*! \} */
124 /*---------------------------------------------------------------------*/
125 /*! \name Error information */
126 /*! \{ */
128 static int getError (void);
129 static int getHostError (void);
130 static std::string getErrorStr (void);
131 static std::string getHostErrorStr(void);
133 /*! \}
135 /*========================== PROTECTED ===============================*/
136 protected:
138 /*! Socket option type. Used to hide the different interface
139 implementations
141 #if defined WIN32
142 typedef char FAR SocketOptT;
143 #else
144 typedef void SocketOptT;
145 #endif
147 /*! Socket length type. Used to hide the different interface
148 implementations
150 #if defined(__linux) || defined(__APPLE__)
151 typedef socklen_t SocketLenT;
152 #else
153 typedef int SocketLenT;
154 #endif
156 /*---------------------------------------------------------------------*/
157 /*! \name member */
158 /*! \{ */
160 int _sd;
162 /*! \} */
163 /*========================== PRIVATE =================================*/
164 private:
166 friend class SocketSelection;
168 /*---------------------------------------------------------------------*/
169 /*! \name static member */
170 /*! \{ */
172 static int initialized;
174 /*! \} */
177 OSG_END_NAMESPACE
179 #endif