TcpInst.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_TCPINST_H
00009 #define OPENDDS_TCPINST_H
00010 
00011 #include "Tcp_export.h"
00012 #include "TcpTransport.h"
00013 
00014 #include "dds/DCPS/transport/framework/TransportInst.h"
00015 #include "dds/DCPS/SafetyProfileStreams.h"
00016 #include "ace/INET_Addr.h"
00017 #include "ace/SString.h"
00018 
00019 #include <string>
00020 
00021 // Forward definition of a test-friendly class in the global name space
00022 class DDS_TEST;
00023 
00024 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 namespace OpenDDS {
00027 namespace DCPS {
00028 
00029 class OpenDDS_Tcp_Export TcpInst
00030   : public TransportInst {
00031 public:
00032   virtual int load(ACE_Configuration_Heap& cf,
00033                    ACE_Configuration_Section_Key& sect);
00034 
00035   /// Diagnostic aid.
00036   virtual OPENDDS_STRING dump_to_str() const;
00037 
00038   /// The address string provided to DCPSInfoRepo for connectors.
00039   /// This string is either from configuration file or defaults
00040   /// to the local address.
00041   std::string pub_address_str_;
00042 
00043   bool enable_nagle_algorithm_;
00044 
00045   /// The initial retry delay in milliseconds.
00046   /// The first connection retry will be when the loss of connection
00047   /// is detected.  The second try will be after this delay.
00048   /// The default is 500 miliseconds.
00049   int conn_retry_initial_delay_;
00050 
00051   /// The backoff multiplier for reconnection strategy.
00052   /// The third and so on reconnect will be this value * the previous delay.
00053   /// Hence with conn_retry_initial_delay=500 and conn_retry_backoff_multiplier=1.5
00054   /// the second reconnect attempt will be at 0.5 seconds after first retry connect
00055   /// fails; the third attempt will be 0.75 seconds after the second retry connect
00056   /// fails; the fourth attempt will be 1.125 seconds after the third retry connect
00057   /// fails.
00058   /// The default value is 2.0.
00059   double conn_retry_backoff_multiplier_;
00060 
00061   /// Number of attemps to reconnect before giving up and calling
00062   /// on_publication_lost() and on_subscription_lost() callbacks.
00063   /// The default is 3.
00064   int conn_retry_attempts_;
00065 
00066   /// Maximum period (in milliseconds) of not being able to send queued
00067   /// messages. If there are samples queued and no output for longer
00068   /// than this period then the connection will be closed and on_*_lost()
00069   /// callbacks will be called. If the value is zero, the default, then
00070   /// this check will not be made.
00071   int max_output_pause_period_;
00072 
00073   /// The time period in milliseconds for the acceptor side
00074   /// of a connection to wait for the connection to be reconnected.
00075   /// If not reconnected within this period then
00076   /// on_publication_lost() and on_subscription_lost() callbacks
00077   /// will be called.
00078   /// The default is 2 seconds (2000 millseconds).
00079   int passive_reconnect_duration_;
00080 
00081   bool is_reliable() const { return true; }
00082 
00083   /// The public address is our publicly advertised address.
00084   /// Usually this is the same as the local address, but if
00085   /// a public address is explicitly specified, use that.
00086   const std::string& get_public_address() const {
00087     return (pub_address_str_ == "") ? local_address_str_ : pub_address_str_;
00088   }
00089 
00090   virtual size_t populate_locator(OpenDDS::DCPS::TransportLocator& trans_info) const;
00091 
00092   OPENDDS_STRING local_address_string() const { return local_address_str_; }
00093   ACE_INET_Addr local_address() const { return local_address_; }
00094   void local_address(const char* str)
00095   {
00096     local_address_str_ = str;
00097     local_address_.set(str);
00098   }
00099   void local_address(u_short port_number, const char* host_name)
00100   {
00101     local_address_str_ = host_name;
00102     local_address_str_ += ":" + to_dds_string(port_number);
00103     local_address_.set(port_number, host_name);
00104   }
00105   void local_address_set_port(u_short port_number) {
00106     local_address_.set_port_number(port_number);
00107     set_port_in_addr_string(local_address_str_, port_number);
00108   }
00109 
00110 private:
00111   friend class TcpType;
00112   friend class TcpTransport;
00113   friend class ::DDS_TEST;
00114   template <typename T, typename U>
00115   friend RcHandle<T> OpenDDS::DCPS::make_rch(U const&);
00116   explicit TcpInst(const OPENDDS_STRING& name);
00117   virtual ~TcpInst();
00118 
00119   TransportImpl_rch new_impl();
00120 
00121   /// Describes the local endpoint to be used to accept
00122   /// passive connections.
00123   ACE_INET_Addr local_address_;
00124 
00125   /// The address string used to configure the acceptor.
00126   /// This string is either from configuration file or default
00127   /// to hostname:port. The hostname is fully qualified hostname
00128   /// and the port is randomly picked by os.
00129   std::string local_address_str_;
00130 };
00131 
00132 } // namespace DCPS
00133 } // namespace OpenDDS
00134 
00135 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00136 
00137 #if defined (__ACE_INLINE__)
00138 #include "TcpInst.inl"
00139 #endif /* __ACE_INLINE__ */
00140 
00141 #endif  /* OPENDDS_TCPINST_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1