本文整理汇总了C++中PacketHdr::setHeaderSize方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketHdr::setHeaderSize方法的具体用法?C++ PacketHdr::setHeaderSize怎么用?C++ PacketHdr::setHeaderSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketHdr
的用法示例。
在下文中一共展示了PacketHdr::setHeaderSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetContent
/*!
\brief Request a certain content by id
Function to send a packet requesting content and to resend the request if not received on the receiving thread
*/
void GetContent(string contentId, struct res *args)
{
Packet *req_packet;
req_packet = new Packet();
req_packet->setPayloadSize(0); //No Payload
PacketHdr *rqhdr = req_packet->accessHeader();
rqhdr->setHeaderSize(3); //Need 3 bytes for the header
rqhdr->setOctet('0',0); //Request packet = type 0
rqhdr->setOctet((char)host_id,2); //Setting host id
int contentId_int = atoi(contentId.c_str());
rqhdr->setOctet((char)contentId_int,1); //Setting content request message
args->my_req_port->sendPacket(req_packet);
args->my_req_port->lastPkt_ = req_packet;
//cout<<"First octet "<<rqhdr->getOctet(0)<<"Second Octet "<<rqhdr->getOctet(1)<<"Third Octet "<<rqhdr->getOctet(2)<<endl;
gettimeofday(&rtt, NULL);
cout<<"Sent Request"<<endl;
args->my_req_port->setACKflag(false);
args->my_req_port->timer_.startTimer(5);
while(!args->my_req_port->isACKed())
{
sleep(1);
if(!args->my_req_port->isACKed())
{
sleep(3);
if(!args->my_req_port->isACKed())
{
sleep(5);
if(!args->my_req_port->isACKed())
{
sleep(7);
if(!args->my_req_port->isACKed())
{
sleep(9);
if(!args->my_req_port->isACKed())
{
cout<<"Giving up.."<<endl;
args->my_req_port->setACKflag(true);
}
}
}
}
}
else{return;}
}
return;
}