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

  1 mday  1.1.2.1 //%///////////////////////-*-c++-*-/////////////////////////////////////////////
  2               //
  3               // Copyright (c) 2001 - 2003  BMC Software, Hewlett-Packard Company, IBM,
  4               // The Open Group, Tivoli Systems
  5               //
  6               // Permission is hereby granted, free of charge, to any person obtaining a copy
  7               // 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               // 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               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14               // 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               // 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               // 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 mday  1.1.2.1 //==============================================================================
 23               //
 24               // Author: Mike Day (mdday@us.ibm.com)
 25               //
 26               // Modified By:
 27               //
 28               //%/////////////////////////////////////////////////////////////////////////////
 29               
 30               
 31               #ifndef peg_socket_class_heirarchy_h
 32               #define peg_socket_class_heirarchy_h
 33               
 34               #include <Pegasus/Common/Config.h>
 35               #include <Pegasus/Common/IPC.h>
 36 mday  1.1.2.2 #include <Pegasus/Common/TLS.h>
 37 mday  1.1.2.1 #ifdef PEGASUS_OS_TYPE_WINDOWS
 38               #include <windows.h>
 39               # ifndef _WINSOCKAPI_
 40               #   include <winsock2.h>
 41               # endif
 42               #else
 43               # include <cctype>
 44               #ifndef PEGASUS_OS_OS400
 45               #   include <unistd.h>
 46               #else
 47               #   include <Pegasus/Common/OS400ConvertChar.h>
 48               #   include <unistd.cleinc>
 49               #endif
 50               #ifdef PEGASUS_OS_ZOS
 51               #   include <string.h>  // added by rk for memcpy
 52               #endif
 53               # include <cstdlib>
 54               # include <errno.h>
 55               # include <fcntl.h>
 56               # include <netdb.h>
 57               # include <netinet/in.h>
 58 mday  1.1.2.1 # include <arpa/inet.h>
 59               # include <sys/socket.h>
 60               #endif
 61               #include <Pegasus/Common/Linkage.h>
 62               
 63               PEGASUS_NAMESPACE_BEGIN
 64               
 65               //  <<< Thu Jul  3 13:50:29 2003 mdd >>> pep_88
 66               /*****************************************************************
 67                *
 68                *  The socket support in pegasus is schizophrenic. Some code uses 
 69                *  an Sint32 (fd) as a socket, while other code uses a pointer to an 
 70                *  MP_Socket, which is kind of a container for either an Sint32 socket 
 71                *  or an SSL socket. 
 72                *
 73                *  Then there is also the local socket. (AF_UNIX). 
 74                *
 75                *  What we need to make all of this coherent is a general-purpose
 76                *  socket class that uses polymorphism to provide a good sockets
 77                *  interface.
 78                *  Because of what we are planning for the pep_88 connection management
 79 mday  1.1.2.1  *  code this general-purpose socket class should be reference counted.
 80                *
 81                *****************************************************************/ 
 82               
 83               class abstract_socket;
 84               class socket_factory;
 85               
 86               
 87               class PEGASUS_COMMON_LINKAGE pegasus_socket 
 88               {
 89               
 90                  public:
 91                     pegasus_socket(void);
 92                     pegasus_socket(socket_factory *);
 93                     pegasus_socket(abstract_socket *);
 94                     pegasus_socket(const pegasus_socket& s);
 95                     ~pegasus_socket(void);
 96                     
 97                     pegasus_socket& operator=(const pegasus_socket& s);
 98                     operator Sint32() const;
 99               
100 mday  1.1.2.1       int socket(int type, int style, int protocol, void *ssl_context = 0);
101                               
102                     Sint32 read(void* ptr, Uint32 size);
103                     Sint32 write(const void* ptr, Uint32 size);
104                     int close(void);
105                     int enableBlocking(void);
106                     int disableBlocking(void);
107               
108                     int getsockname (struct sockaddr *addr, size_t *length_ptr);
109                     int bind (struct sockaddr *addr, size_t length);
110                    
111                     // change size_t to size_t for ZOS and windows
112                     pegasus_socket accept(struct sockaddr *addr, size_t *length_ptr);
113                     int connect (struct sockaddr *addr, size_t length);
114                     int shutdown(int how);
115                     int listen(int q);
116                     int getpeername (struct sockaddr *addr, size_t *length_ptr);
117                     int send (void *buffer, size_t size, int flags);
118                     int recv (void *buffer, size_t size, int flags);
119                     int sendto(void *buffer, size_t size, int flags, struct sockaddr *addr, size_t length);
120                     int recvfrom(void *buffer, size_t size, int flags, struct sockaddr *addr, size_t *length_ptr);
121 mday  1.1.2.1       int setsockopt (int level, int optname, void *optval, size_t optlen);
122                     int getsockopt (int level, int optname, void *optval, size_t *optlen_ptr);
123               
124               
125                     Boolean incompleteReadOccurred(Sint32 retCode);
126                     Boolean is_secure(void);
127                     void set_close_on_exec(void);
128                     
129                     const char* get_err_string(void);
130                     
131                  private:
132               
133                     abstract_socket * _rep;
134               
135               };
136               
137               
138               class PEGASUS_COMMON_LINKAGE socket_factory 
139               {
140                  public:
141                     socket_factory(void)
142 mday  1.1.2.1       {
143                     }
144                     
145                     virtual ~socket_factory(void)
146                     {
147                     }
148                     
149                     virtual abstract_socket *make_socket(void) = 0;
150 mday  1.1.2.2 #ifdef PEGASUS_HAS_SSL
151                     virtual abstract_socket *make_socket(SSLContext *) = 0;
152               #endif
153 mday  1.1.2.1 };
154               
155               
156 mday  1.1.2.2 
157 mday  1.1.2.1 /**
158                *  factory class for creating the bsd socket object 
159                **/
160               class PEGASUS_COMMON_LINKAGE bsd_socket_factory : public socket_factory
161               {
162                  public:
163                     bsd_socket_factory(void);
164                     ~bsd_socket_factory(void);
165                     abstract_socket *make_socket(void);
166 mday  1.1.2.2 #ifdef PEGASUS_HAS_SSL
167                     abstract_socket *make_socket(SSLContext* );
168               #endif
169               };
170               
171               
172               
173               #ifdef PEGASUS_HAS_SSL
174               
175               class PEGASUS_COMMON_LINKAGE ssl_socket_factory : public socket_factory
176               {
177               
178                  public:
179                     ssl_socket_factory(void);
180                     ~ssl_socket_factory(void);
181                     abstract_socket* make_socket(void);
182                     abstract_socket* make_socket(SSLContext* );
183 mday  1.1.2.1 };
184               
185 mday  1.1.2.2 
186               
187               #endif 
188               
189               
190               # ifdef PEGASUS_LOCAL_DOMAIN_SOCKET
191               
192               class PEGASUS_COMMON_LINKAGE unix_socket_factory : public socket_factory
193               {
194                  public:
195                     unix_socket_factory(void);
196                     ~unix_socket_factory(void);
197                     abstract_socket* make_socket(void);
198               };
199               
200               
201               #endif
202 mday  1.1.2.1 
203               PEGASUS_NAMESPACE_END
204               
205               #endif /* peg_socket_class_heirarchy_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2