SOCK_SEQPACK_Acceptor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SOCK_SEQPACK_Acceptor.h
00006  *
00007  *  SOCK_SEQPACK_Acceptor.h,v 1.14 2005/11/26 03:13:13 ossama Exp
00008  *  @author  Patrick J. Lardieri <plardier@atl.lmco.com>
00009  *  @author  Gaurav Naik, Lockheed Martin ATL
00010  *  @author  based on SOCK_STREAM_Acceptor
00011  *            by Douglas C. Schmidt <schmidt@cs.wustl.edu>
00012  *
00013  */
00014 //=============================================================================
00015 
00016 #ifndef ACE_SOCK_SEQ_ACCEPTOR_H
00017 #define ACE_SOCK_SEQ_ACCEPTOR_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include "ace/ACE_export.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #include "ace/SOCK_SEQPACK_Association.h"
00028 #include "ace/Multihomed_INET_Addr.h"
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 class ACE_Time_Value;
00033 
00034 /**
00035  * @class ACE_SOCK_SEQPACK_Acceptor
00036  *
00037  * @brief Defines a factory that creates new <ACE_Association>s passively.
00038  *
00039  * The <ACE_SOCK_SEQPACK_Acceptor> has its own "passive-mode" socket.
00040  * This serves as a factory to create so-called "data-mode"
00041  * sockets, which are what the <ACE_SOCK_SEQPACK_Association> encapsulates.
00042  * Therefore, by inheriting from <ACE_SOCK>, <ACE_SOCK_SEQPACK_Acceptor>
00043  * gets its very own socket.
00044  */
00045 class ACE_Export ACE_SOCK_SEQPACK_Acceptor : public ACE_SOCK
00046 {
00047 public:
00048   // = Initialization and termination methods.
00049   /// Default constructor.
00050   ACE_SOCK_SEQPACK_Acceptor (void);
00051 
00052   /**
00053    * Initialize a passive-mode BSD-style acceptor socket (no QoS).
00054    * <local_sap> is the address that we're going to listen for
00055    * connections on.  If <reuse_addr> is 1 then we'll use the
00056    * <SO_REUSEADDR> to reuse this address.
00057    */
00058   ACE_SOCK_SEQPACK_Acceptor (const ACE_Addr &local_sap,
00059                      int reuse_addr = 0,
00060                      int protocol_family = PF_UNSPEC,
00061                      int backlog = ACE_DEFAULT_BACKLOG,
00062                      int protocol = 132);
00063 
00064   /// Multihomed version of same
00065 
00066   ACE_SOCK_SEQPACK_Acceptor (const ACE_Multihomed_INET_Addr &local_sap,
00067                      int reuse_addr = 0,
00068                      int protocol_family = PF_UNSPEC,
00069                      int backlog = ACE_DEFAULT_BACKLOG,
00070                      int protocol = 132);
00071 
00072   /// Initialize a passive-mode QoS-enabled acceptor socket.  Returns 0
00073   /// on success and -1 on failure.
00074   ACE_SOCK_SEQPACK_Acceptor (const ACE_Addr &local_sap,
00075                      ACE_Protocol_Info *protocolinfo,
00076                      ACE_SOCK_GROUP g,
00077                      u_long flags,
00078                      int reuse_addr,
00079                      int protocol_family = PF_UNSPEC,
00080                      int backlog = ACE_DEFAULT_BACKLOG,
00081                      int protocol = 132);
00082 
00083 
00084   /**
00085    * Initialize a passive-mode BSD-style acceptor socket (no QoS).
00086    * <local_sap> is the address that we're going to listen for
00087    * connections on.  If <reuse_addr> is 1 then we'll use the
00088    * <SO_REUSEADDR> to reuse this address.  Returns 0 on success and
00089    * -1 on failure.
00090    */
00091   int open (const ACE_Addr &local_sap,
00092             int reuse_addr = 0,
00093             int protocol_family = PF_UNSPEC,
00094             int backlog = ACE_DEFAULT_BACKLOG,
00095             int protocol = 132);
00096 
00097   /// Multihomed version of same
00098 
00099   int open (const ACE_Multihomed_INET_Addr &local_sap,
00100             int reuse_addr = 0,
00101             int protocol_family = PF_UNSPEC,
00102             int backlog = ACE_DEFAULT_BACKLOG,
00103             int protocol = 132);
00104 
00105 
00106   /// Initialize a passive-mode QoS-enabled acceptor socket.  Returns 0
00107   /// on success and -1 on failure.
00108   int open (const ACE_Addr &local_sap,
00109             ACE_Protocol_Info *protocolinfo,
00110             ACE_SOCK_GROUP g,
00111             u_long flags,
00112             int reuse_addr,
00113             int protocol_family = PF_UNSPEC,
00114             int backlog = ACE_DEFAULT_BACKLOG,
00115             int protocol = 132);
00116 
00117   /// Close the socket.  Returns 0 on success and -1 on failure.
00118   int close (void);
00119 
00120   /// Default dtor.
00121   ~ACE_SOCK_SEQPACK_Acceptor (void);
00122 
00123   // = Passive connection <accept> methods.
00124   /**
00125    * Accept a new <ACE_SOCK_SEQPACK_Association> connection.  A <timeout> of 0
00126    * means block forever, a <timeout> of {0, 0} means poll.  <restart>
00127    * == 1 means "restart if interrupted," i.e., if errno == EINTR.
00128    * Note that <new_association> inherits the "blocking mode" of <this>
00129    * <ACE_SOCK_SEQPACK_Acceptor>, i.e., if <this> acceptor factory is in
00130    * non-blocking mode, the <net_association> will be in non-blocking mode
00131    * and vice versa.
00132    */
00133   int accept (ACE_SOCK_SEQPACK_Association &new_association,
00134               ACE_Addr *remote_addr = 0,
00135               ACE_Time_Value *timeout = 0,
00136               int restart = 1,
00137               int reset_new_handle = 0) const;
00138 
00139   // = Meta-type info
00140   typedef ACE_Multihomed_INET_Addr PEER_ADDR;
00141   typedef ACE_SOCK_SEQPACK_Association PEER_STREAM;
00142 
00143   /// Dump the state of an object.
00144   void dump (void) const;
00145 
00146   /// Declare the dynamic allocation hooks.
00147   ACE_ALLOC_HOOK_DECLARE;
00148 
00149 protected:
00150   /// Perform operations that must occur before <ACE_OS::accept> is
00151   /// called.
00152   int shared_accept_start (ACE_Time_Value *timeout,
00153                            int restart,
00154                            int &in_blocking_mode) const;
00155 
00156   /// Perform operations that must occur after <ACE_OS::accept> is
00157   /// called.
00158   int shared_accept_finish (ACE_SOCK_SEQPACK_Association new_association,
00159                             int in_blocking_mode,
00160                             int reset_new_handle) const;
00161 
00162   /**
00163    * This method factors out the common <open> code and is called by
00164    * both the QoS-enabled <open> method and the BSD-style <open>
00165    * method.
00166    */
00167   int shared_open (const ACE_Addr &local_sap,
00168                    int protocol_family,
00169                    int backlog);
00170 
00171   /// Multihomed version of same.
00172 
00173   int shared_open (const ACE_Multihomed_INET_Addr &local_sap,
00174                    int protocol_family,
00175                    int backlog);
00176 
00177 private:
00178   /// Do not allow this function to percolate up to this interface...
00179   int get_remote_addr (ACE_Addr &) const;
00180 };
00181 
00182 ACE_END_VERSIONED_NAMESPACE_DECL
00183 
00184 #if defined (__ACE_INLINE__)
00185 #include "ace/SOCK_SEQPACK_Acceptor.inl"
00186 #endif /* __ACE_INLINE__ */
00187 
00188 #include /**/ "ace/post.h"
00189 
00190 #endif /* ACE_SOCK_SEQ_ACCEPTOR_H */

Generated on Thu Nov 9 09:42:04 2006 for ACE by doxygen 1.3.6