void OpenDDS::DCPS::TcpDataLink::send_graceful_disconnect_message() { DBG_ENTRY_LVL("TcpDataLink","send_graceful_disconnect_message",6); // Will clear all queued messages but still let the disconnect message // sent. this->send_strategy_->terminate_send(true); DataSampleHeader header_data; // The message_id_ is the most important value for the DataSampleHeader. header_data.message_id_ = GRACEFUL_DISCONNECT; // Other data in the DataSampleHeader are not necessary set. The bogus values // can be used. //header_data.byte_order_ // = this->transport_->get_configuration()->swap_bytes() ? !TAO_ENCAP_BYTE_ORDER : TAO_ENCAP_BYTE_ORDER; //header_data.message_length_ = 0; //header_data.sequence_ = 0; //DDS::Time_t source_timestamp // = OpenDDS::DCPS::time_value_to_time (ACE_OS::gettimeofday ()); //header_data.source_timestamp_sec_ = source_timestamp.sec; //header_data.source_timestamp_nanosec_ = source_timestamp.nanosec; //header_data.coherency_group_ = 0; //header_data.publication_id_ = 0; // TODO: // It seems a bug in the transport implementation that the receiving side can // not receive the message when the message has no sample data and is sent // in a single packet. // To work arround this problem, I have to add bogus data to chain with the // DataSampleHeader to make the receiving work. ACE_Message_Block* message; size_t max_marshaled_size = header_data.max_marshaled_size(); ACE_Message_Block* data = 0; ACE_NEW(data, ACE_Message_Block(20, ACE_Message_Block::MB_DATA, 0, //cont 0, //data 0, //allocator_strategy 0, //locking_strategy ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY, ACE_Time_Value::zero, ACE_Time_Value::max_time, 0, 0)); data->wr_ptr(20); header_data.message_length_ = static_cast<ACE_UINT32>(data->length()); ACE_NEW(message, ACE_Message_Block(max_marshaled_size, ACE_Message_Block::MB_DATA, data, //cont 0, //data 0, //allocator_strategy 0, //locking_strategy ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY, ACE_Time_Value::zero, ACE_Time_Value::max_time, 0, 0)); *message << header_data; TransportControlElement* send_element = 0; ACE_NEW(send_element, TransportControlElement(message)); // give the message block ownership to TransportControlElement message->release(); // I don't want to rebuild a connection in order to send // a graceful disconnect message. this->send_i(send_element, false); }
void OpenDDS::DCPS::SimpleTcpDataLink::fully_associated() { DBG_ENTRY_LVL("SimpleTcpDataLink","fully_associated",6); while (!this->connection_->is_connected()) { ACE_Time_Value tv(0, 100000); ACE_OS::sleep(tv); } this->resume_send(); bool swap_byte = this->transport_->get_configuration()->swap_bytes_; DataSampleHeader header_data; // The message_id_ is the most important value for the DataSampleHeader. header_data.message_id_ = FULLY_ASSOCIATED; // Other data in the DataSampleHeader are not necessary set. The bogus values // can be used. header_data.byte_order_ = swap_byte ? !TAO_ENCAP_BYTE_ORDER : TAO_ENCAP_BYTE_ORDER; //header_data.message_length_ = 0; //header_data.sequence_ = 0; //DDS::Time_t source_timestamp // = OpenDDS::DCPS::time_value_to_time (ACE_OS::gettimeofday ()); //header_data.source_timestamp_sec_ = source_timestamp.sec; //header_data.source_timestamp_nanosec_ = source_timestamp.nanosec; //header_data.coherency_group_ = 0; //header_data.publication_id_ = 0; ACE_Message_Block* message; size_t max_marshaled_size = header_data.max_marshaled_size(); ACE_Message_Block* data = this->marshal_acks(swap_byte); header_data.message_length_ = data->length(); ACE_NEW(message, ACE_Message_Block(max_marshaled_size, ACE_Message_Block::MB_DATA, data, //cont 0, //data 0, //allocator_strategy 0, //locking_strategy ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY, ACE_Time_Value::zero, ACE_Time_Value::max_time, 0, 0)); message << header_data; TransportControlElement* send_element = 0; ACE_NEW(send_element, TransportControlElement(message)); // give the message block ownership to TransportControlElement message->release (); this->send_i(send_element); }