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

  1 mday  1.5.12.1 //%///////////////////////-*-c++-*-/////////////////////////////////////////////
  2 mike  1.2      //
  3 kumpf 1.4      // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4 mike  1.2      // The Open Group, Tivoli Systems
  5                //
  6                // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.4      // of this software and associated documentation files (the "Software"), to
  8                // deal in the Software without restriction, including without limitation the
  9                // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 mike  1.2      // sell copies of the Software, and to permit persons to whom the Software is
 11                // furnished to do so, subject to the following conditions:
 12                // 
 13 kumpf 1.4      // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.2      // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15                // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.4      // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17                // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18                // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 mike  1.2      // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20                // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21                //
 22                //==============================================================================
 23                //
 24                // Author: Mike Brasher (mbrasher@bmc.com)
 25                //
 26                // Modified By:
 27                //
 28                //%/////////////////////////////////////////////////////////////////////////////
 29                
 30                #ifndef Pegasus_Socket_h
 31                #define Pegasus_Socket_h
 32                
 33                #include <Pegasus/Common/Config.h>
 34 mday  1.5.12.1 #include <Pegasus/Common/IPC.h>
 35                #ifdef PEGASUS_OS_TYPE_WINDOWS
 36                #include <windows.h>
 37                # ifndef _WINSOCKAPI_
 38                #   include <winsock2.h>
 39                # endif
 40                #else
 41                # include <cctype>
 42                #ifndef PEGASUS_OS_OS400
 43                #   include <unistd.h>
 44                #else
 45                #   include <Pegasus/Common/OS400ConvertChar.h>
 46                #   include <unistd.cleinc>
 47                #endif
 48                #ifdef PEGASUS_OS_ZOS
 49                #   include <string.h>  // added by rk for memcpy
 50                #endif
 51                # include <cstdlib>
 52                # include <errno.h>
 53                # include <fcntl.h>
 54                # include <netdb.h>
 55 mday  1.5.12.1 # include <netinet/in.h>
 56                # include <arpa/inet.h>
 57                # include <sys/socket.h>
 58                #endif
 59 kumpf 1.5      #include <Pegasus/Common/Linkage.h>
 60 mike  1.2      
 61                PEGASUS_NAMESPACE_BEGIN
 62                
 63 kumpf 1.3      class PEGASUS_COMMON_LINKAGE Socket
 64 mike  1.2      {
 65 mday  1.5.12.2    public:
 66 mike  1.2      
 67                
 68 mday  1.5.12.2       static Sint32 read(Sint32 socket, void* ptr, Uint32 size);
 69 mike  1.2      
 70 mday  1.5.12.2       static Sint32 write(Sint32 socket, const void* ptr, Uint32 size);
 71 mike  1.2      
 72 mday  1.5.12.2       static void close(Sint32 socket);
 73                      static int close2(Sint32 socket);
 74                      
 75                      static void enableBlocking(Sint32 socket);
 76                      static int  enableBlocking2(Sint32 socket);
 77 mike  1.2      
 78 mday  1.5.12.2       static void disableBlocking(Sint32 socket);
 79                      static int disableBlocking2(Sint32 socket);
 80 mike  1.2      
 81 mday  1.5.12.2       static void initializeInterface(void);
 82                      static void uninitializeInterface(void);
 83                      
 84 mike  1.2      
 85 mday  1.5.12.2    private:
 86 mike  1.2      
 87 mday  1.5.12.2       Socket() { }
 88 mike  1.2      };
 89 mday  1.5.12.1 
 90                
 91                
 92                
 93                
 94                
 95                //  <<< Thu Jul  3 13:50:29 2003 mdd >>> pep_88
 96                /*****************************************************************
 97                 *
 98                 *  The socket support in pegasus is schizophrenic. Some code uses 
 99                 *  an Sint32 (fd) as a socket, while other code uses a pointer to an 
100                 *  MP_Socket, which is kind of a container for either an Sint32 socket 
101                 *  or an SSL socket. 
102                 *
103                 *  Then there is also the local socket. (AF_UNIX). 
104                 *
105                 *  What we need to make all of this coherent is a general-purpose
106                 *  socket class that uses polymorphism to provide a good sockets
107                 *  interface.
108                 *  Because of what we are planning for the pep_88 connection management
109                 *  code this general-purpose socket class should be reference counted.
110 mday  1.5.12.1  *
111                 *****************************************************************/ 
112                
113                
114                
115                class PEGASUS_COMMON_LINKAGE pegasus_socket 
116                {
117                
118                   public:
119                
120                      pegasus_socket(void);
121                      pegasus_socket(const pegasus_socket& s);
122                      ~pegasus_socket(void);
123                      
124                      pegasus_socket& operator=(const pegasus_socket& s);
125                      operator Sint32() const;
126                
127                      int socket(int type, int style, int protocol);
128                      int socket(int type, int style, int protocol, void *ssl_context = 0);
129                      
130                      
131 mday  1.5.12.1       
132                      Sint32 read(void* ptr, Uint32 size);
133                      Sint32 write(const void* ptr, Uint32 size);
134                      int close(void);
135 mday  1.5.12.2       int enableBlocking(void);
136                      int disableBlocking(void);
137 mday  1.5.12.1 
138                      int getsockname (struct sockaddr *addr, size_t *length_ptr);
139                      int bind (struct sockaddr *addr, size_t length);
140                     
141                      // change size_t to size_t for ZOS and windows
142                      pegasus_socket accept(struct sockaddr *addr, size_t *length_ptr);
143 mday  1.5.12.2       int connect (struct sockaddr *addr, size_t length);
144 mday  1.5.12.1       int shutdown(int how);
145                      int listen(int q);
146                      int getpeername (struct sockaddr *addr, size_t *length_ptr);
147                      int send (void *buffer, size_t size, int flags);
148                      int recv (void *buffer, size_t size, int flags);
149                      int sendto(void *buffer, size_t size, int flags, struct sockaddr *addr, size_t length);
150                      int recvfrom(void *buffer, size_t size, int flags, struct sockaddr *addr, size_t *length_ptr);
151                      int setsockopt (int level, int optname, void *optval, size_t optlen);
152                      int getsockopt (int level, int optname, void *optval, size_t *optlen_ptr);
153                
154                
155                      Boolean incompleteReadOccurred(Sint32 retCode);
156                      Boolean is_secure(void);
157                      void set_close_on_exec(void);
158                      
159                      const char* get_err_string(void);
160                      
161                   private:
162                      class abstract_socket;
163                      abstract_socket * _rep;
164                
165 mday  1.5.12.1       static const char *_err_strings[];
166                      int _type;
167                      int _style;
168                      int _protocol;
169                
170                };
171                
172                
173                
174                
175                
176                
177 mike  1.2      
178                PEGASUS_NAMESPACE_END
179                
180                #endif /* Pegasus_Socket_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2