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

MEM_Acceptor.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    MEM_Acceptor.h
00006  *
00007  *  $Id: MEM_Acceptor.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Nanbor Wang <nanbor@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_MEM_ACCEPTOR_H
00015 #define ACE_MEM_ACCEPTOR_H
00016 #include "ace/pre.h"
00017 
00018 #include "ace/SOCK_Acceptor.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00025 
00026 #include "ace/MEM_Stream.h"
00027 #include "ace/MEM_Addr.h"
00028 
00029 #if !defined (ACE_HAS_WINCE)
00030 #include "ace/OS_QoS.h"
00031 #endif  // ACE_HAS_WINCE
00032 
00033 // Forward decl.
00034 class ACE_Reactor;
00035 
00036 /**
00037  * @class ACE_MEM_Acceptor
00038  *
00039  * @brief Defines the format and interface for the acceptor side of the
00040  * local mmap stream.
00041  *
00042  * This class should be modified to prevent user passing a
00043  * non-localhost endpoint as the acceptor listen point because
00044  * it doesn't make any sense at all to make the listening
00045  * endpoint visible (or connectable) anywhere outside of this
00046  * machine.  However, the type of endpoint is left as <ACE_Addr>
00047  * so we can later changed to use UNIX sockets with mmap stream
00048  * if so desired.  (Currently, using UNIX socket with this class
00049  * will not work.)
00050  */
00051 class ACE_Export ACE_MEM_Acceptor : public ACE_SOCK_Acceptor
00052 {
00053 public:
00054   // = Initialization methods.
00055   /// Default constructor.
00056   ACE_MEM_Acceptor (void);
00057 
00058   /// destructor.
00059   ~ACE_MEM_Acceptor (void);
00060 
00061   /// Initiate a passive mode socket.
00062   ACE_MEM_Acceptor (const ACE_MEM_Addr &remote_sap,
00063                     int reuse_addr = 0,
00064                     int backlog = ACE_DEFAULT_BACKLOG,
00065                     int protocol = 0);
00066 
00067   /**
00068    * Initialize a passive-mode BSD-style acceptor socket (no QoS).
00069    * <local_sap> is the address that we're going to listen for
00070    * connections on.  If <reuse_addr> is 1 then we'll use the
00071    * <SO_REUSEADDR> to reuse this address.  Returns 0 on success and
00072    * -1 on failure.
00073    */
00074   int open (const ACE_MEM_Addr &local_sap,
00075             int reuse_addr = 0,
00076             int backlog = ACE_DEFAULT_BACKLOG,
00077             int protocol = 0);
00078 
00079   /// Accept a new data transfer connection.
00080   int accept (ACE_MEM_Stream &new_ipc_sap,
00081               ACE_MEM_Addr *remote_addr = 0,
00082               ACE_Time_Value *timeout = 0,
00083               int restart = 1,
00084               int reset_new_handle = 0);
00085 
00086   /// Perform operations that must occur after <ACE_OS::accept> is
00087   /// called.
00088   int shared_accept_finish (ACE_MEM_Stream new_stream,
00089                             int in_blocking_mode,
00090                             int reset_new_handle) const;
00091 
00092   /**
00093    * Accessor/mutator of mmap filename prefix.  By default, the
00094    * <mmap_prefix_> is not set and the mmap filename is
00095    * ${(TMP|TEMP)}//ACE_MEM_Acceptor_(port-number)_(&stream),
00096    * otherwise, it is <mmap_prefix_>_(port-number)_(&stream),
00097    * <mmap_prefix_> should include _absolute_ path so the connector
00098    * within the same host can located the mmap file.  Example:
00099    * /tmp/mmapfile.
00100    */
00101   const ACE_TCHAR *mmap_prefix (void) const;
00102   void mmap_prefix (const ACE_TCHAR *prefix);
00103 
00104   /// Get the preferred signaling strategy.
00105   ACE_MEM_IO::Signal_Strategy preferred_strategy (void) const;
00106 
00107   /// Set the preferred signaling strategy.
00108   void preferred_strategy (ACE_MEM_IO::Signal_Strategy strategy);
00109 
00110   /// Return the local endpoint address in the referenced <ACE_Addr>.
00111   /// Returns 0 if successful, else -1.
00112   int get_local_addr (ACE_MEM_Addr &) const;
00113 
00114   /// Accessor to the mmap options.
00115   ACE_MEM_SAP::MALLOC_OPTIONS& malloc_options (void);
00116 
00117   // = Meta-type info
00118   typedef ACE_MEM_Addr PEER_ADDR;
00119   typedef ACE_MEM_Stream PEER_STREAM;
00120 
00121   /// Dump the state of an object.
00122   void dump (void) const;
00123 
00124   /// Declare the dynamic allocation hooks.
00125   ACE_ALLOC_HOOK_DECLARE;
00126 
00127 protected:
00128   // = The following methods should not be accessable externally
00129   //   because MEM_Acceptor do not support their semantics.
00130   int open (const ACE_Addr &local_sap,
00131             int reuse_addr = 0,
00132             int protocol_family = PF_INET,
00133             int backlog = ACE_DEFAULT_BACKLOG,
00134             int protocol = 0);
00135 
00136   int open (const ACE_Addr &local_sap,
00137             ACE_Protocol_Info *protocolinfo,
00138             ACE_SOCK_GROUP g,
00139             u_long flags,
00140             int reuse_addr,
00141             int protocol_family,
00142             int backlog = ACE_DEFAULT_BACKLOG,
00143             int protocol = 0);
00144 
00145   int accept (ACE_SOCK_Stream &new_stream,
00146               ACE_Addr *remote_addr = 0,
00147               ACE_Time_Value *timeout = 0,
00148               int restart = 1,
00149               int reset_new_handle = 0) const;
00150 
00151 #if !defined (ACE_HAS_WINCE)
00152   int accept (ACE_SOCK_Stream &new_stream,
00153               ACE_Accept_QoS_Params qos_params,
00154               ACE_Addr *remote_addr = 0,
00155               ACE_Time_Value *timeout = 0,
00156               int restart = 1,
00157               int reset_new_handle = 0) const;
00158 #endif  // ACE_HAS_WINCE
00159 
00160 private:
00161   /// The filename prefix of the created mmap files.  It should
00162   /// contains the absolute path name of the file.
00163   ACE_TCHAR *mmap_prefix_;
00164 
00165   /// A cached MALLOC_OPTIONS.  MEM_Accaptor use it to create the shared
00166   /// mamory malloc upon every incoming connection.
00167   ACE_MEM_SAP::MALLOC_OPTIONS malloc_options_;
00168 
00169   /// Preferred signaling strategy.
00170   ACE_MEM_IO::Signal_Strategy preferred_strategy_;
00171 };
00172 
00173 #if !defined (ACE_LACKS_INLINE_FUNCTIONS)
00174 #include "ace/MEM_Acceptor.i"
00175 #endif /* ACE_LACKS_INLINE_FUNCTIONS */
00176 
00177 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00178 
00179 #include "ace/post.h"
00180 #endif /* ACE_MEM_ACCEPTOR_H */

Generated on Mon Jun 16 11:20:16 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002