Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

SSL_SOCK_Acceptor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SSL_SOCK_Acceptor.h
00006  *
00007  *  $Id: SSL_SOCK_Acceptor.h,v 1.1.1.2 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author John Heitmann
00010  *  @author Chris Zimman
00011  *  @author Ossama Othman <ossama@uci.edu>
00012  */
00013 //=============================================================================
00014 
00015 
00016 #ifndef ACE_SSL_SOCK_ACCEPTOR_H
00017 #define ACE_SSL_SOCK_ACCEPTOR_H
00018 
00019 #include "ace/pre.h"
00020 
00021 #include "SSL_Export.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #include "SSL_SOCK_Stream.h"
00028 
00029 #include "ace/SOCK_Acceptor.h"
00030 #include "ace/OS_QoS.h"
00031 
00032 /**
00033  * @class ACE_SSL_SOCK_Acceptor
00034  *
00035  * @brief Defines a factory that creates new @c ACE_SSL_SOCK_Stream
00036  * objects passively.
00037  *
00038  * The ACE_SSL_SOCK_Acceptor has its own @c ACE_SOCK_Acceptor
00039  * which handles the basic socket acceptance.  This class is a
00040  * wrapper which adds the SSL acceptance handshake handling.
00041  * Since SSL is record oriented, some additional steps must be taken
00042  * after the basic socket acceptance to complete the SSL handshake that
00043  * takes place at session establishment.
00044  *
00045  * @note The user must currently ensure that only one thread services
00046  *       a given SSL session at any given time since some underlying
00047  *       SSL implementations, such as OpenSSL, are not entirely
00048  *       thread-safe or reentrant.
00049  */
00050 class ACE_SSL_Export ACE_SSL_SOCK_Acceptor : public ACE_SSL_SOCK
00051 {
00052 public:
00053 
00054   /// Default constructor.
00055   ACE_SSL_SOCK_Acceptor (void);
00056 
00057   /// Default destructor.
00058   ~ACE_SSL_SOCK_Acceptor (void);
00059 
00060   /**
00061    * Initiate a passive mode SSL/BSD-style acceptor socket.
00062    * @param local_sap  The address that we're going to listen for
00063    *                   connections on. If this is @c ACE_Addr::sap_any,
00064    *                   this socket listens on an the "any" IP address
00065    *                   and selects an unused port. To find out what port
00066    *                   was selected, call this object's
00067    *                   @c ACE_SOCK::get_local_addr(ACE_Addr&) method
00068    *                   upon return.
00069    */
00070   ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap,
00071                          int reuse_addr = 0,
00072                          int protocol_family = PF_UNSPEC,
00073                          int backlog = ACE_DEFAULT_BACKLOG,
00074                          int protocol = 0);
00075 
00076   /**
00077    * Initiate a passive-mode QoS-enabled acceptor socket.
00078    * @param local_sap  The address that we're going to listen for
00079    *                   connections on. If this is @c ACE_Addr::sap_any,
00080    *                   this socket listens on an the "any" IP address
00081    *                   and selects an unused port. To find out what port
00082    *                   was selected, call this object's
00083    *                   @c ACE_SOCK::get_local_addr(ACE_Addr&) method
00084    *                   upon return.
00085    */
00086   ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap,
00087                          ACE_Protocol_Info *protocolinfo,
00088                          ACE_SOCK_GROUP g,
00089                          u_long flags,
00090                          int reuse_addr,
00091                          int protocol_family = PF_UNSPEC,
00092                          int backlog = ACE_DEFAULT_BACKLOG,
00093                          int protocol = 0);
00094 
00095   /**
00096    * Initiate a passive mode SSL/BSD-style acceptor socket.
00097    * @param local_sap  The address that we're going to listen for
00098    *                   connections on. If this is @c ACE_Addr::sap_any,
00099    *                   this socket listens on an the "any" IP address
00100    *                   and selects an unused port. To find out what port
00101    *                   was selected, call this object's
00102    *                   @c ACE_SOCK::get_local_addr(ACE_Addr&) method
00103    *                   upon return.
00104    *
00105    * @return 0 if success; -1 for failure (errno contains error code).
00106    */
00107   int open (const ACE_Addr &local_sap,
00108             int reuse_addr = 0,
00109             int protocol_family = PF_UNSPEC,
00110             int backlog = ACE_DEFAULT_BACKLOG,
00111             int protocol = 0);
00112 
00113   /// Close the listening socket.
00114   int close (void);
00115 
00116   /**
00117    * @name Passive Connection "accept" Methods
00118    *
00119    * These are the canonical methods exposed by the Acceptor pattern.
00120    */
00121   //@{
00122   /**
00123    * Accept a new ACE_SSL_SOCK_Stream connection. On successful return,
00124    * the socket has been accepted and the SSL handshake has been completed.
00125    * @param new_stream  The @c ACE_SSL_SOCK_Stream object that will receive
00126    *                    the new SSL socket.
00127    * @param remote_addr Pointer to an @c ACE_INET_Addr object that will
00128    *                    receive the address of the peer that connected.
00129    * @param timeout     The maximum time to wait for the combined socket
00130    *                    acceptance and handshake completion. 0 means
00131    *                    block forever, a timeout of {0, 0} means poll.
00132    * @param restart     1 means "restart if interrupted," that is,
00133    *                    if errno == EINTR.
00134    *
00135    * @return 0 if success; -1 for failure (errno contains error code).
00136    */
00137   int accept (ACE_SSL_SOCK_Stream &new_stream,
00138               ACE_Addr *remote_addr = 0,
00139               ACE_Time_Value *timeout = 0,
00140               int restart = 1,
00141               int reset_new_handle = 0) const;
00142 
00143   /**
00144    * Accept a new ACE_SSL_SOCK_Stream connection using the RVSP QoS
00145    * information in qos_params.
00146    * @param new_stream  The @c ACE_SSL_SOCK_Stream object that will receive
00147    *                    the new SSL socket.
00148    * @param remote_addr Pointer to an @c ACE_INET_Addr object that will
00149    *                    receive the address of the peer that connected.
00150    * @param timeout     The maximum time to wait for the combined socket
00151    *                    acceptance and handshake completion. 0 means
00152    *                    block forever, a timeout of {0, 0} means poll.
00153    * @param restart     1 means "restart if interrupted," that is,
00154    *                    if errno == EINTR.
00155    *
00156    * @return 0 if success; -1 for failure (errno contains error code).
00157    */
00158   int accept (ACE_SSL_SOCK_Stream &new_stream,
00159               ACE_Accept_QoS_Params qos_params,
00160               ACE_Addr *remote_addr = 0,
00161               ACE_Time_Value *timeout = 0,
00162               int restart = 1,
00163               int reset_new_handle = 0) const;
00164   //@}
00165 
00166   /// Meta-type info
00167   //@{
00168   typedef ACE_INET_Addr PEER_ADDR;
00169   typedef ACE_SSL_SOCK_Stream PEER_STREAM;
00170   //@}
00171 
00172   /// Declare the dynamic allocation hooks.
00173   ACE_ALLOC_HOOK_DECLARE;
00174 
00175 protected:
00176 
00177   /// Complete SSL passive connection establishment.
00178   int ssl_accept (ACE_SSL_SOCK_Stream &new_stream,
00179                   ACE_Time_Value *timeout) const;
00180 
00181 private:
00182 
00183   /// The BSD-socket workhorse
00184   ACE_SOCK_Acceptor acceptor_;
00185 
00186 };
00187 
00188 #if !defined (ACE_LACKS_INLINE_FUNCTIONS)
00189 #include "SSL_SOCK_Acceptor.i"
00190 #endif /* ACE_LACKS_INLINE_FUNCTIONS */
00191 
00192 #include "ace/post.h"
00193 
00194 #endif /* ACE_SSL_SOCK_ACCEPTOR_H */
00195 

Generated on Mon Jun 16 13:15:55 2003 for ACE_SSL by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002