(file) Return to Network.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 mike  1.1 //%2006////////////////////////////////////////////////////////////////////////
  2           //
  3           // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4           // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5           // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6           // IBM Corp.; EMC Corporation, The Open Group.
  7           // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8           // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9           // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10           // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11           // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12           // EMC Corporation; Symantec Corporation; The Open Group.
 13           //
 14           // Permission is hereby granted, free of charge, to any person obtaining a copy
 15           // of this software and associated documentation files (the "Software"), to
 16           // deal in the Software without restriction, including without limitation the
 17           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18           // sell copies of the Software, and to permit persons to whom the Software is
 19           // furnished to do so, subject to the following conditions:
 20           // 
 21           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29           //
 30           //==============================================================================
 31           //
 32           //%/////////////////////////////////////////////////////////////////////////////
 33           
 34           #ifndef Pegasus_Network_h
 35           #define Pegasus_Network_h
 36           
 37           #include <Pegasus/Common/Config.h>
 38           
 39           //==============================================================================
 40           //
 41           // Network.h
 42           //
 43 mike  1.1 //     This file includes network-related system-header files. Please include
 44           //     this file directly rather than including system headers directly. If
 45           //     special inclusions are necessary for any platform, please add them to
 46 kumpf 1.8 //     this file rather than other files. The reason for this file is to limit
 47           //     platform-specific conditional compilation expressions to only a few
 48 mike  1.1 //     well-known header files.
 49 kumpf 1.8 //
 50 mike  1.1 //==============================================================================
 51           
 52           //------------------------------------------------------------------------------
 53           //
 54           // PEGASUS_OS_TYPE_WINDOWS network system header files
 55           //
 56           //------------------------------------------------------------------------------
 57           
 58           #ifdef PEGASUS_OS_TYPE_WINDOWS
 59           #   ifdef FD_SETSIZE
 60 kumpf 1.8 #       error "<Pegasus/Common/Network.h>: FD_SETSIZE is already defined. \
 61            This file must be included prior to any header file that defines \
 62            FD_SETSIZE, such as <windows.h>, <winsock.h>, or <winsock2.h>."
 63 mike  1.1 #   endif
 64           #   define FD_SETSIZE 1024
 65           #   include <windows.h>
 66           #   ifndef _WINSOCKAPI_
 67           #       include <winsock2.h>
 68           #   endif
 69           #   include <wincrypt.h>
 70           #endif
 71           
 72           //------------------------------------------------------------------------------
 73           //
 74 carson.hovey 1.4 // PEGASUS_OS_TYPE_UNIX or PEGASUS_OS_VMS network system header files.
 75 mike         1.1 //
 76                  //------------------------------------------------------------------------------
 77                  
 78 carson.hovey 1.4 #if defined(PEGASUS_OS_TYPE_UNIX) || defined (PEGASUS_OS_VMS)
 79 mike         1.1 #   include <errno.h>
 80                  #   include <sys/types.h>
 81                  #   include <fcntl.h>
 82                  #   include <netdb.h>
 83                  #   include <netinet/in.h>
 84                  #   include <arpa/inet.h>
 85                  #   include <sys/socket.h>
 86                  #   include <sys/time.h>
 87 kumpf        1.7 #   ifndef PEGASUS_OS_HPUX
 88                  #       include <net/if.h>
 89                  #   endif
 90 thilo.boehm  1.6 #   include <sys/ioctl.h>
 91 mike         1.1 #   ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 92                  #       include <unistd.h>
 93                  #       include <sys/un.h>
 94                  #   endif
 95                  #   ifdef PEGASUS_OS_OS400
 96                  #       include <unistd.cleinc>
 97                  #   else
 98                  #       include <unistd.h>
 99                  #   endif
100                  #   ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
101                  #       ifndef TCP_NODELAY
102                  #           define TCP_NODELAY 1
103                  #       endif
104                  #   else
105                  #       include <netinet/tcp.h>
106                  #   endif
107                  #endif
108                  
109                  //------------------------------------------------------------------------------
110                  //
111                  // PEGASUS_SOCKET_ERROR
112 mike         1.1 //
113                  //------------------------------------------------------------------------------
114                  
115                  #ifdef PEGASUS_OS_TYPE_WINDOWS
116                  #   define PEGASUS_SOCKET_ERROR SOCKET_ERROR
117                  #else
118                  #   define PEGASUS_SOCKET_ERROR (-1)
119                  #endif
120                  
121 thilo.boehm  1.6 //------------------------------------------------------------------------------
122                  //
123                  // PEGASUS_NETWORK_TCPIP_STOPPED
124 kumpf        1.8 //
125                  // This return code indicates that the transpor layer is
126 thilo.boehm  1.6 // stopped and the socket is invalid. The socket must created again.
127                  //
128                  //------------------------------------------------------------------------------
129                  
130                  #ifdef PEGASUS_OS_ZOS
131                  #   define PEGASUS_NETWORK_TCPIP_STOPPED EIO
132                  #else
133                  #   define PEGASUS_NETWORK_TCPIP_STOPPED 0
134                  #endif
135                  
136                  //------------------------------------------------------------------------------
137                  //
138                  // PEGASUS_NETWORK_TCPIP_TRYAGAIN
139 kumpf        1.8 //
140 thilo.boehm  1.6 // This return code indicates that the transport layer is
141                  // temporary unavailable and the program can try again.
142                  //
143                  //------------------------------------------------------------------------------
144                  
145                  #ifdef PEGASUS_OS_ZOS
146                  #   define PEGASUS_NETWORK_TCPIP_TRYAGAIN EAGAIN
147                  #else
148                  #   define PEGASUS_NETWORK_TCPIP_TRYAGAIN 0
149                  #endif
150                  
151                  //------------------------------------------------------------------------------
152                  //
153                  // PEGASUS_NETWORK_TRYAGAIN
154 kumpf        1.8 //
155                  // This return code indicates that the network function
156 thilo.boehm  1.6 // should be tried again by the program.
157                  //
158                  //------------------------------------------------------------------------------
159                  
160                  #if !defined(PEGASUS_OS_TYPE_WINDOWS)
161                  #   define PEGASUS_NETWORK_TRYAGAIN EAGAIN
162                  #else
163                  #   define PEGASUS_NETWORK_TRYAGAIN 0
164                  #endif
165                  
166 kumpf        1.3 ////////////////////////////////////////////////////////////////////////////////
167                  //
168                  // getSocketError()
169                  //
170                  ////////////////////////////////////////////////////////////////////////////////
171                  
172                  static inline int getSocketError()
173                  {
174                  #ifdef PEGASUS_OS_TYPE_WINDOWS
175                      return WSAGetLastError();
176                  #else
177                      return errno;
178                  #endif
179                  }
180                  
181 mike         1.1 //------------------------------------------------------------------------------
182                  //
183                  // PEGASUS_INVALID_SOCKET
184                  //
185                  //------------------------------------------------------------------------------
186                  
187                  #ifdef PEGASUS_OS_TYPE_WINDOWS
188                  #   define PEGASUS_INVALID_SOCKET INVALID_SOCKET
189                  #else
190                  #   define PEGASUS_INVALID_SOCKET (-1)
191                  #endif
192                  
193                  //------------------------------------------------------------------------------
194                  //
195                  // SocketHandle
196                  //
197                  //------------------------------------------------------------------------------
198                  
199                  #ifdef PEGASUS_OS_TYPE_WINDOWS
200                  typedef SOCKET SocketHandle;
201                  #else
202 mike         1.1 typedef int SocketHandle;
203                  #endif
204                  
205                  //------------------------------------------------------------------------------
206                  //
207 mike         1.2 // SocketLength
208 mike         1.1 //
209                  //------------------------------------------------------------------------------
210                  
211 kumpf        1.5 #if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) || \
212 mike         1.1     defined(PEGASUS_PLATFORM_SOLARIS_SPARC_GNU) || \
213                      defined(PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX) || \
214 a.dunfey     1.9     defined(PEGASUS_PLATFORM_WIN64_IA64_MSVC) || \
215                      defined(PEGASUS_PLATFORM_WIN64_X86_64_MSVC) || \
216 mike         1.1     defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
217 mike         1.2     typedef int SocketLength;
218                  #elif defined(PEGASUS_PLATFORM_VMS_ALPHA_DECCXX) || \
219 mike         1.1     defined(PEGASUS_PLATFORM_VMS_IA64_DECCXX) || \
220                      defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
221 mike         1.2     typedef size_t SocketLength;
222                  #elif defined(PEGASUS_PLATFORM_HPUX_IA64_ACC) && \
223 mike         1.1     !defined(_XOPEN_SOURCE_EXTENDED)
224 mike         1.2     typedef int SocketLength;
225                  #elif defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC) && \
226 mike         1.1     !defined(_XOPEN_SOURCE_EXTENDED)
227 mike         1.2     typedef int SocketLength;
228                  #elif defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC) && \
229 mike         1.1     defined(SUNOS_5_6)
230 mike         1.2     typedef int SocketLength;
231                  #else
232                      typedef socklen_t SocketLength;
233 mike         1.1 #endif
234                  
235                  #endif  /* Pegasus_Network_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2