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

MEM_Connector.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    MEM_Connector.h
00006  *
00007  *  $Id: MEM_Connector.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 #ifndef ACE_MEM_CONNECTOR_H
00014 #define ACE_MEM_CONNECTOR_H
00015 #include "ace/pre.h"
00016 
00017 #include "ace/SOCK_Connector.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00024 
00025 #include "ace/MEM_Stream.h"
00026 #include "ace/MEM_Addr.h"
00027 
00028 /**
00029  * @class ACE_MEM_Connector
00030  *
00031  * @brief Defines the format and interface for connecting to a peer
00032  * on a @c ACE_MEM_Stream object.
00033  */
00034 class ACE_Export ACE_MEM_Connector : public ACE_SOCK_Connector
00035 {
00036 public:
00037   // = Initialization methods.
00038   /// Default constructor.
00039   ACE_MEM_Connector (void);
00040 
00041   /**
00042    * Actively connect to a peer, producing a connected @c ACE_MEM_Stream
00043    * object if the connection succeeds.
00044    *
00045    * @param new_stream  The @c ACE_MEM_Stream object that will be connected
00046    *                    to the peer.
00047    * @param remote_sap  The address that we are trying to connect to.
00048    *                    The protocol family of @c remote_sap is used for
00049    *                    the connected socket. That is, if @c remote_sap
00050    *                    contains an IPv6 address, a socket with family
00051    *                    PF_INET6 will be used, else it will be PF_INET.
00052    *                    @note remote_sap must be an address on the local
00053    *                    host.
00054    * @param timeout     Pointer to an @c ACE_Time_Value object with amount
00055    *                    of time to wait to connect. If the pointer is 0
00056    *                    then the call blocks until the connection attempt
00057    *                    is complete, whether it succeeds or fails.  If
00058    *                    *timeout == {0, 0} then the connection is done
00059    *                    using nonblocking mode.  In this case, if the
00060    *                    connection can't be made immediately, this method
00061    *                    returns -1 and errno == EWOULDBLOCK.
00062    *                    If *timeout > {0, 0} then this is the maximum amount
00063    *                    of time to wait before timing out; if the specified
00064    *                    amount of time passes before the connection is made,
00065    *                    this method returns -1 and errno == ETIME. Note
00066    *                    the difference between this case and when a blocking
00067    *                    connect is attmpted that TCP times out - in the latter
00068    *                    case, errno will be ETIMEDOUT.
00069    * @param local_sap   (optional) The local address to bind to.  If it's
00070    *                    the default value of @c ACE_Addr::sap_any then the
00071    *                    OS will choose an unused port.
00072    * @param reuse_addr  (optional) If the value is 1, the local address
00073    *                    (@c local_sap) is reused, even if it hasn't been
00074    *                    cleaned up yet.
00075    * @param flags       Ignored.
00076    * @param perms       Ignored.
00077    */
00078   ACE_MEM_Connector (ACE_MEM_Stream &new_stream,
00079                      const ACE_INET_Addr &remote_sap,
00080                      ACE_Time_Value *timeout = 0,
00081                      const ACE_Addr &local_sap = ACE_Addr::sap_any,
00082                      int reuse_addr = 0,
00083                      int flags = 0,
00084                      int perms = 0);
00085 
00086   /**
00087    * Actively connect to a peer, producing a connected @c ACE_MEM_Stream
00088    * object if the connection succeeds.
00089    *
00090    * @param new_stream  The @c ACE_MEM_Stream object that will be connected
00091    *                    to the peer.
00092    * @param remote_sap  The address that we are trying to connect to.
00093    *                    The protocol family of @c remote_sap is used for
00094    *                    the connected socket. That is, if @c remote_sap
00095    *                    contains an IPv6 address, a socket with family
00096    *                    PF_INET6 will be used, else it will be PF_INET.
00097    *                    @note remote_sap must be an address on the local
00098    *                    host.
00099    * @param timeout     Pointer to an @c ACE_Time_Value object with amount
00100    *                    of time to wait to connect. If the pointer is 0
00101    *                    then the call blocks until the connection attempt
00102    *                    is complete, whether it succeeds or fails.  If
00103    *                    *timeout == {0, 0} then the connection is done
00104    *                    using nonblocking mode.  In this case, if the
00105    *                    connection can't be made immediately, this method
00106    *                    returns -1 and errno == EWOULDBLOCK.
00107    *                    If *timeout > {0, 0} then this is the maximum amount
00108    *                    of time to wait before timing out; if the specified
00109    *                    amount of time passes before the connection is made,
00110    *                    this method returns -1 and errno == ETIME. Note
00111    *                    the difference between this case and when a blocking
00112    *                    connect is attmpted that TCP times out - in the latter
00113    *                    case, errno will be ETIMEDOUT.
00114    * @param local_sap   (optional) The local address to bind to.  If it's
00115    *                    the default value of @c ACE_Addr::sap_any then the
00116    *                    OS will choose an unused port.
00117    * @param reuse_addr  (optional) If the value is 1, the local address
00118    *                    (@c local_sap) is reused, even if it hasn't been
00119    *                    cleaned up yet.
00120    * @param flags       Ignored.
00121    * @param perms       Ignored.
00122    *
00123    * @return            Returns 0 if the connection succeeds. If it fails,
00124    *                    -1 is returned and errno contains a specific error
00125    *                    code.
00126    */
00127   int connect (ACE_MEM_Stream &new_stream,
00128                const ACE_INET_Addr &remote_sap,
00129                ACE_Time_Value *timeout = 0,
00130                const ACE_Addr &local_sap = ACE_Addr::sap_any,
00131                int reuse_addr = 0,
00132                int flags = 0,
00133                int perms = 0);
00134 
00135   /// Get the preferred signaling strategy.
00136   ACE_MEM_IO::Signal_Strategy preferred_strategy (void) const;
00137 
00138   /// Set the preferred signaling strategy.
00139   void preferred_strategy (ACE_MEM_IO::Signal_Strategy strategy);
00140 
00141   /// Accessor to underlying malloc options.
00142   ACE_MEM_SAP::MALLOC_OPTIONS &malloc_options (void);
00143 
00144   // = Meta-type info
00145   typedef ACE_INET_Addr PEER_ADDR;
00146   typedef ACE_MEM_Stream PEER_STREAM;
00147 
00148   /// Dump the state of an object.
00149   void dump (void) const;
00150 
00151   /// Declare the dynamic allocation hooks.
00152   ACE_ALLOC_HOOK_DECLARE;
00153 
00154 private:
00155   /// The acceptor address this connector is connecting to.
00156   ACE_MEM_Addr address_;
00157 
00158   /// A cached MALLOC_OPTIONS that the MEM_Connector used to initialize
00159   /// the shared memory malloc update connection establishment.
00160   ACE_MEM_SAP::MALLOC_OPTIONS malloc_options_;
00161 
00162   /// Preferred signaling strategy.
00163   ACE_MEM_IO::Signal_Strategy preferred_strategy_;
00164 };
00165 
00166 #if !defined (ACE_LACKS_INLINE_FUNCTIONS)
00167 #include "ace/MEM_Connector.i"
00168 #endif
00169 
00170 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00171 
00172 #include "ace/post.h"
00173 #endif /* ACE_MEM_CONNECTOR_H */

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