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 namespace OpenDDS {
00025 namespace DCPS {
00026 
00027 class OpenDDS_Tcp_Export TcpInst
00028   : public TransportInst {
00029 public:
00030   virtual int load(ACE_Configuration_Heap& cf,
00031                    ACE_Configuration_Section_Key& sect);
00032 
00033   /// Diagnostic aid.
00034   virtual OPENDDS_STRING dump_to_str();
00035 
00036   /// The address string provided to DCPSInfoRepo for connectors.
00037   /// This string is either from configuration file or defaults
00038   /// to the local address.
00039   std::string pub_address_str_;
00040 
00041   bool enable_nagle_algorithm_;
00042 
00043   /// The initial retry delay in milliseconds.
00044   /// The first connection retry will be when the loss of connection
00045   /// is detected.  The second try will be after this delay.
00046   /// The default is 500 miliseconds.
00047   int conn_retry_initial_delay_;
00048 
00049   /// The backoff multiplier for reconnection strategy.
00050   /// The third and so on reconnect will be this value * the previous delay.
00051   /// Hence with conn_retry_initial_delay=500 and conn_retry_backoff_multiplier=1.5
00052   /// the second reconnect attempt will be at 0.5 seconds after first retry connect
00053   /// fails; the third attempt will be 0.75 seconds after the second retry connect
00054   /// fails; the fourth attempt will be 1.125 seconds after the third retry connect
00055   /// fails.
00056   /// The default value is 2.0.
00057   double conn_retry_backoff_multiplier_;
00058 
00059   /// Number of attemps to reconnect before giving up and calling
00060   /// on_publication_lost() and on_subscription_lost() callbacks.
00061   /// The default is 3.
00062   int conn_retry_attempts_;
00063 
00064   /// Maximum period (in milliseconds) of not being able to send queued
00065   /// messages. If there are samples queued and no output for longer
00066   /// than this period then the connection will be closed and on_*_lost()
00067   /// callbacks will be called. If the value is zero, the default, then
00068   /// this check will not be made.
00069   int max_output_pause_period_;
00070 
00071   /// The time period in milliseconds for the acceptor side
00072   /// of a connection to wait for the connection to be reconnected.
00073   /// If not reconnected within this period then
00074   /// on_publication_lost() and on_subscription_lost() callbacks
00075   /// will be called.
00076   /// The default is 2 seconds (2000 millseconds).
00077   int passive_reconnect_duration_;
00078 
00079   bool is_reliable() const { return true; }
00080 
00081   /// The public address is our publicly advertised address.
00082   /// Usually this is the same as the local address, but if
00083   /// a public address is explicitly specified, use that.
00084   const std::string& get_public_address() const {
00085     return (pub_address_str_ == "") ? local_address_str_ : pub_address_str_;
00086   }
00087 
00088   virtual size_t populate_locator(OpenDDS::DCPS::TransportLocator& trans_info) const;
00089 
00090   OPENDDS_STRING local_address_string() const { return local_address_str_; }
00091   ACE_INET_Addr local_address() const { return local_address_; }
00092   void local_address(const char* str)
00093   {
00094     local_address_str_ = str;
00095     local_address_.set(str);
00096   }
00097   void local_address(u_short port_number, const char* host_name)
00098   {
00099     local_address_str_ = host_name;
00100     local_address_str_ += ":" + to_dds_string(port_number);
00101     local_address_.set(port_number, host_name);
00102   }
00103   void local_address_set_port(u_short port_number) {
00104     local_address_.set_port_number(port_number);
00105     size_t pos = local_address_str_.find_last_of(":");
00106     OPENDDS_STRING host_name = local_address_str_.substr(0, pos);
00107     local_address_str_ = host_name + ":" + to_dds_string(port_number);
00108   }
00109 
00110 private:
00111   friend class TcpType;
00112   friend class TcpTransport;
00113   friend class ::DDS_TEST;
00114   explicit TcpInst(const OPENDDS_STRING& name);
00115   virtual ~TcpInst();
00116 
00117   TcpTransport* new_impl(const TransportInst_rch& inst);
00118 
00119   /// Describes the local endpoint to be used to accept
00120   /// passive connections.
00121   ACE_INET_Addr local_address_;
00122 
00123   /// The address string used to configure the acceptor.
00124   /// This string is either from configuration file or default
00125   /// to hostname:port. The hostname is fully qualified hostname
00126   /// and the port is randomly picked by os.
00127   std::string local_address_str_;
00128 };
00129 
00130 } // namespace DCPS
00131 } // namespace OpenDDS
00132 
00133 #if defined (__ACE_INLINE__)
00134 #include "TcpInst.inl"
00135 #endif /* __ACE_INLINE__ */
00136 
00137 #endif  /* OPENDDS_TCPINST_H */

Generated on Fri Feb 12 20:05:27 2016 for OpenDDS by  doxygen 1.4.7