本文整理汇总了C++中ACE_OutputCDR类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_OutputCDR类的具体用法?C++ ACE_OutputCDR怎么用?C++ ACE_OutputCDR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_OutputCDR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StreamTo
CmResult COFP13MPAggregateFlowStatsRequestMsg::
StreamTo(ACE_OutputCDR &os)
{
if (COFP13MultipartMsg::StreamTo(os) != CM_OK)
{
return CM_ERROR_FAILURE;
}
os<<m_stats_request.table_id;
os.write_octet_array(m_stats_request.pad, sizeof(m_stats_request.pad));
os<<m_stats_request.out_port;
os<<m_stats_request.out_group;
os.write_octet_array(m_stats_request.pad2, sizeof(m_stats_request.pad2));
os<<m_stats_request.cookie;
os<<m_stats_request.cookie_mask;
bool bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
return m_match.StreamTo(os);
}
示例2: network_order_address
void PubDriver::add_subscription (
CORBA::Long reader_id,
const char * sub_addr
)
{
::OpenDDS::DCPS::ReaderAssociationSeq associations;
associations.length (1);
associations[0].readerTransInfo.transport_id = 1; // TBD - not right
OpenDDS::DCPS::NetworkAddress network_order_address(sub_addr);
ACE_OutputCDR cdr;
cdr << network_order_address;
size_t len = cdr.total_length ();
associations[0].readerTransInfo.data
= OpenDDS::DCPS::TransportInterfaceBLOB
(len,
len,
(CORBA::Octet*)(cdr.buffer ()));
associations[0].readerId = reader_id;
associations[0].subQos = TheServiceParticipant->initial_SubscriberQos ();
associations[0].readerQos = TheServiceParticipant->initial_DataReaderQos ();
OpenDDS::DCPS::RepoId pub_id = foo_datawriter_servant_->get_publication_id();
datawriter_servant_->add_associations (pub_id, associations);
}
示例3: serialize
static void serialize( ACE_OutputCDR& cdr, const LifeCycleFrame& frame ) {
cdr.write_ushort( frame.endian_mark_ );
cdr.write_ushort( frame.proto_version_ );
cdr.write_ushort( frame.ctrl_);
cdr.write_ushort( frame.hoffset_ );
cdr.write_ulong( frame.command_ );
}
示例4: addr
int logClient::process(ACE_CString* s){
ACE_SOCK_Stream logger;
ACE_SOCK_Connector connector;
ACE_INET_Addr addr(9876, "127.0.0.1");
if(connector.connect(logger, addr) == -1){
ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%p \n"), ACE_TEXT("open")), -1);
}
ACE_Log_Record record(LM_DEBUG,
ACE_OS::time ((time_t *) 0),
ACE_OS::getpid());
record.msg_data(s.c_str());
const size_t max_payload_size =
4
+ 8
+ 4
+ 4
+ ACE_Log_Record::MAXLOGMSGLEN
+ ACE_CDR::MAX_ALIGNMENT;
ACE_OutputCDR payload(max_payload_size);
payload<< record;
ACE_CDR::ULong length =
ACE_Utils::truncate_cast<ACE_CDR::ULong> (payload.total_length());
ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8);
header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
header << ACE_CDR::ULong(length);
iovec iov[2];
iov[0].iov_base = header.begin() -> rd_ptr();
iov[0].iov_len = 8;
iov[1].iov_base = payload.begin() -> rd_ptr();
iov[1].iov_len = length;
if (logger.sendv_n(iov, 2) == -1)
ACE_ERROR_RETURN((LM_ERROR,"%p\n","send"), -1);
/*
*/
ACE_Message_Block* header_p;
auto_ptr<ACE_Message_Block> header(header_p);
ACE_CDR::mb_align(header.get());
ACE_Message_Block* payload_p;
ssize_t count = logger.recv_n(header->wr_ptr(),8);
switch(count){
default:
case -1:
case 0:
case 8:
break;
}
header->wr_ptr(8);
}
示例5:
void
tofSession_i::tof_debug( const CORBA::WChar * text, const CORBA::WChar * key )
{
ACE_OutputCDR cdr;
cdr.write_wstring( text );
cdr.write_wstring( key );
ACE_Message_Block * mb = cdr.begin()->duplicate();
mb->msg_type( constants::MB_DEBUG );
pTask_->putq( mb );
}
示例6: network_address
bool
MulticastTransport::connection_info_i(TransportLocator& info) const
{
NetworkAddress network_address(this->config_i_->group_address_);
ACE_OutputCDR cdr;
cdr << network_address;
const CORBA::ULong len = static_cast<CORBA::ULong>(cdr.total_length());
char* buffer = const_cast<char*>(cdr.buffer()); // safe
info.transport_type = "multicast";
info.data = TransportBLOB(len, len, reinterpret_cast<CORBA::Octet*>(buffer));
return true;
}
示例7: sendHeader
// send the test header (only contains number of iterations)
int sendHeader(ACE_SOCK_Stream & stream) {
// create an ACE CDR output stream and place the header information
// into it
ACE_OutputCDR hdrCDR;
hdrCDR << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
hdrCDR << ACE_CDR::ULong(Options_Manager::test_iterations+primerIterations);
if (!hdrCDR.good_bit())
return (0);
// send the header to the server (HEADER IS 8 BYTES LONG)
size_t bt;
if (stream.send_n(hdrCDR.begin(), 0, &bt) == -1)
return 0;
return 1;
}
示例8:
ACE_CDR::Boolean
ACE_IBM1047_ISO8859::write_string (ACE_OutputCDR& out,
ACE_CDR::ULong len,
const ACE_CDR::Char* x)
{
if (out.write_ulong (len + 1))
return this->write_char_array (out, x, len + 1);
return 0;
}
示例9: network_order_address
void
SubDriver::run()
{
// Set up the publications.
OpenDDS::DCPS::AssociationData publications[1];
publications[0].remote_id_ = this->pub_id_;
publications[0].remote_data_.transport_id = 2; // TBD later - wrong
OpenDDS::DCPS::NetworkAddress network_order_address(this->pub_addr_str_);
ACE_OutputCDR cdr;
cdr << network_order_address;
size_t len = cdr.total_length ();
publications[0].remote_data_.data
= OpenDDS::DCPS::TransportInterfaceBLOB
(len,
len,
(CORBA::Octet*)(cdr.buffer ()));
// Write a file so that test script knows we're ready
FILE * file = ACE_OS::fopen ("subready.txt", "w");
ACE_OS::fprintf (file, "Ready\n");
ACE_OS::fclose (file);
this->subscriber_.init(ALL_TRAFFIC,
this->sub_id_,
1, /* size of publications array */
publications,
this->num_msgs_);
// Wait until we receive our expected message from the remote
// publisher. For this test, we should wait until we receive the
// "Hello World!" message that we expect. Then this program
// can just shutdown.
while (this->subscriber_.received_test_message() == 0)
{
ACE_OS::sleep(1);
}
// Tear-down the entire Transport Framework.
TheTransportFactory->release();
TheServiceParticipant->shutdown();
}
示例10: network_address
size_t
UdpInst::populate_locator(OpenDDS::DCPS::TransportLocator& info) const
{
if (this->local_address_ != ACE_INET_Addr()) {
NetworkAddress network_address(this->local_address_,
this->local_address_.is_any());
ACE_OutputCDR cdr;
cdr << network_address;
const CORBA::ULong len = static_cast<CORBA::ULong>(cdr.total_length());
char* buffer = const_cast<char*>(cdr.buffer()); // safe
info.transport_type = "udp";
info.data = TransportBLOB(len, len, reinterpret_cast<CORBA::Octet*>(buffer));
return 1;
} else {
return 0;
}
}
示例11: ACE_DEBUG
/**
* UDPGenerator::gloveDgramWrite
*
* @param remotehost
* @param remoteport
* @param glovedata
*
* @return
*/
int UDPGenerator::gloveDgramWrite(
const ACE_TCHAR * remotehost,
u_short remoteport,
const DataGloveData &glovedata)
{
ACE_DEBUG ((LM_DEBUG, "Sender::initiate_write called\n"));
const size_t max_payload_size =
4 //boolean alignment flag
+ 4 //payload length
+ glovedata.length // Data Glove data length
+ ACE_CDR::MAX_ALIGNMENT; //pading
// Rescuer header
u_short myid = htons(5);
u_short mysize = htons(max_payload_size);
ACE_Message_Block* rescuerheader= 0;
ACE_NEW_RETURN(rescuerheader, ACE_Message_Block(4), -1);
rescuerheader->copy((const char *)&myid, 2);
rescuerheader->copy((const char *)&mysize, 2);
// My DGS stuff (header and payload)
ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8);
header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
header << ACE_CDR::ULong(length);
// DGS Payload
ACE_OutputCDR payload (max_payload_size);
payload << glovedata;
ACE_CDR::ULong length = payload.total_length();
iovec iov[3];
iov[0].iov_base = rescuerheader->rd_ptr();
iov[0].iov_len = 4;
iov[1].iov_base = header.begin()->rd_ptr();
iov[1].iov_len = HEADER_SIZE;
iov[2].iov_base = payload.begin()->rd_ptr();
iov[2].iov_len = length;
ACE_INET_Addr serverAddr(remoteport, remotehost);
return sockDgram_.send(iov,3, serverAddr );
}
示例12: while
CmResult COFP10PacketOutMsg::StreamTo(ACE_OutputCDR &os)
{
CmResult lRet = CM_ERROR_FAILURE;
lRet = COFPMessage::StreamTo(os);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP10PacketOutMsg::StreamTo, COFPMessage::StreamTo fail\n")));
return lRet;
}
os<<m_tMember.buffer_id;
os<<m_tMember.in_port;
os<<m_tMember.actions_len;
bool bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
std::list<COFP10Action *>::const_iterator it = m_action_list.begin();
while (it != m_action_list.end())
{
lRet = (*it)->StreamTo(os);
CM_ASSERT_RETURN(CM_SUCCEEDED(lRet), CM_ERROR_FAILURE);
it++;
}
if (m_PacketData)
{
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("COFP10PacketOutMsg::StreamTo, m_PacketData->total_length() = %u\n"),
m_PacketData->total_length()));
std::string str = m_PacketData->flatten_chained();
os.write_char_array(str.c_str(), str.length());
}
bGood = os.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
return CM_OK;
}
示例13: DBG_ENTRY_LVL
bool
TcpTransport::connection_info_i(TransportLocator& local_info) const
{
DBG_ENTRY_LVL("TcpTransport", "connection_info_i", 6);
VDBG_LVL((LM_DEBUG, "(%P|%t) TcpTransport public address str %C\n",
this->tcp_config_->get_public_address().c_str()), 2);
// Get the public address string from the inst (usually the local address)
NetworkAddress network_order_address(this->tcp_config_->get_public_address());
ACE_OutputCDR cdr;
cdr << network_order_address;
const CORBA::ULong len = static_cast<CORBA::ULong>(cdr.total_length());
char* buffer = const_cast<char*>(cdr.buffer()); // safe
local_info.transport_type = "tcp";
local_info.data = TransportBLOB(len, len,
reinterpret_cast<CORBA::Octet*>(buffer));
return true;
}
示例14: ACE_ERROR_RETURN
int DataWrapper::write(const ACE_OutputCDR& cdr)
{
//This method writes to an ace socket stream. First, it will collect
//the appropriate header which includes the message length. It will then
//combine ACE blocks that hold the header and message, and send it.
//If preparing the block or sending fails, it returns an appropriate error.
//If the actual socket send fails, the connection will be closed (not sure what
//else to do, since it shouldn't fail under a good connection)
if(!cdr.good_bit())
ACE_ERROR_RETURN((LM_ERROR, "%s, %p\n",toString(theAddress).c_str(),"Failed while sending CDR"), -1);
ACE_OutputCDR aceHead(headerLength);
//Put header info into a CDR
if(!(aceHead << (ACE_CDR::ULong)bitsForward) || !(aceHead << (ACE_CDR::ULong)cdr.length()))
ACE_ERROR_RETURN( (LM_ERROR, "%s, %p\n",toString(theAddress).c_str(),"Failed while sending, CDR header"), -1 );
//Create a block with the header and message
const_cast<ACE_Message_Block*>(aceHead.begin())->cont(const_cast<ACE_Message_Block*>(cdr.begin()));
const ssize_t msgLength = headerLength + ACE_CDR::total_length(cdr.begin(), cdr.end());
// cout << toString(theAddress) << endl;
//Send the message
const ssize_t bytesSent = theStream.send_n(aceHead.begin());
// Clear the block
const_cast<ACE_Message_Block*>(aceHead.begin())->cont(NULL);
//Check whether the send succeeded (sent all the bytes). If not, we assume the socket has disconnected.
// cout << "Bytes sent: " << bytesSent << " | msgLength: " << msgLength << endl;
if( bytesSent != msgLength ) {
theStream.close_writer();
ACE_ERROR_RETURN((LM_ERROR, "%s - %p\n",toString(theAddress).c_str(),"Socket failed while sending"), -1);
}
//Everything sent successfully
return 0;
}
示例15: defined
int
operator<< (ACE_OutputCDR &cdr,
const ACE_Log_Record &log_record)
{
// The written message length can't be more than 32 bits (ACE_CDR::ULong)
// so reduce it here if needed.
ACE_CDR::ULong u_msglen =
ACE_Utils::truncate_cast<ACE_CDR::ULong> (log_record.msg_data_len ());
// Insert each field from <log_record> into the output CDR stream.
cdr << ACE_CDR::Long (log_record.type ());
cdr << ACE_CDR::Long (log_record.pid ());
cdr << ACE_CDR::LongLong (log_record.time_stamp ().sec ());
cdr << ACE_CDR::Long (log_record.time_stamp ().usec ());
cdr << u_msglen;
#if defined (ACE_USES_WCHAR)
cdr.write_wchar_array (log_record.msg_data (), u_msglen);
#else
cdr.write_char_array (log_record.msg_data (), u_msglen);
#endif /* ACE_USES_WCHAR */
return cdr.good_bit ();
}