TcpInst.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "Tcp_pch.h"
00009 #include "TcpInst.h"
00010
00011 #include "dds/DCPS/transport/framework/NetworkAddress.h"
00012
00013 #include "ace/Configuration.h"
00014
00015 #include <iostream>
00016 #include <sstream>
00017
00018 #if !defined (__ACE_INLINE__)
00019 #include "TcpInst.inl"
00020 #endif
00021
00022 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00023
00024 OpenDDS::DCPS::TcpInst::~TcpInst()
00025 {
00026 DBG_ENTRY_LVL("TcpInst","~TcpInst",6);
00027 }
00028
00029 OpenDDS::DCPS::TransportImpl_rch
00030 OpenDDS::DCPS::TcpInst::new_impl()
00031 {
00032 return make_rch<TcpTransport>(ref(*this));
00033 }
00034
00035 int
00036 OpenDDS::DCPS::TcpInst::load(ACE_Configuration_Heap& cf,
00037 ACE_Configuration_Section_Key& trans_sect)
00038 {
00039 TransportInst::load(cf, trans_sect);
00040
00041 std::string local_address;
00042 GET_CONFIG_STRING_VALUE(cf, trans_sect, ACE_TEXT("local_address"), local_address);
00043
00044 if (local_address != "") {
00045 this->local_address(local_address.c_str());
00046 }
00047
00048 GET_CONFIG_STRING_VALUE(cf, trans_sect, ACE_TEXT("pub_address"), pub_address_str_);
00049
00050 GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("enable_nagle_algorithm"),
00051 this->enable_nagle_algorithm_, bool)
00052
00053 GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_initial_delay"),
00054 this->conn_retry_initial_delay_, int)
00055
00056 GET_CONFIG_DOUBLE_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_backoff_multiplier"),
00057 this->conn_retry_backoff_multiplier_)
00058
00059 GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_attempts"),
00060 this->conn_retry_attempts_, int)
00061
00062 GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("passive_reconnect_duration"),
00063 this->passive_reconnect_duration_, int)
00064
00065 GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("max_output_pause_period"),
00066 this->max_output_pause_period_, int)
00067
00068 return 0;
00069 }
00070
00071 OPENDDS_STRING
00072 OpenDDS::DCPS::TcpInst::dump_to_str() const
00073 {
00074 std::ostringstream os;
00075 os << TransportInst::dump_to_str() << std::endl;
00076
00077 os << formatNameForDump("local_address") << this->local_address_string() << std::endl;
00078 os << formatNameForDump("pub_address") << this->pub_address_str_ << std::endl;
00079 os << formatNameForDump("enable_nagle_algorithm") << (this->enable_nagle_algorithm_ ? "true" : "false") << std::endl;
00080 os << formatNameForDump("conn_retry_initial_delay") << this->conn_retry_initial_delay_ << std::endl;
00081 os << formatNameForDump("conn_retry_backoff_multiplier") << this->conn_retry_backoff_multiplier_ << std::endl;
00082 os << formatNameForDump("conn_retry_attempts") << this->conn_retry_attempts_ << std::endl;
00083 os << formatNameForDump("passive_reconnect_duration") << this->passive_reconnect_duration_ << std::endl;
00084 os << formatNameForDump("max_output_pause_period") << this->max_output_pause_period_ << std::endl;
00085 return OPENDDS_STRING(os.str());
00086 }
00087
00088 size_t
00089 OpenDDS::DCPS::TcpInst::populate_locator(OpenDDS::DCPS::TransportLocator& local_info) const
00090 {
00091 if (this->local_address() != ACE_INET_Addr() || !pub_address_str_.empty()) {
00092
00093 NetworkAddress network_order_address(this->get_public_address());
00094
00095 ACE_OutputCDR cdr;
00096 cdr << network_order_address;
00097 const CORBA::ULong len = static_cast<CORBA::ULong>(cdr.total_length());
00098 char* buffer = const_cast<char*>(cdr.buffer());
00099
00100 local_info.transport_type = "tcp";
00101 local_info.data = TransportBLOB(len, len,
00102 reinterpret_cast<CORBA::Octet*>(buffer));
00103 return 1;
00104 } else {
00105 return 0;
00106 }
00107 }
00108
00109 OPENDDS_END_VERSIONED_NAMESPACE_DECL