本文整理汇总了C++中OutputBuffer::setInitSeq方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputBuffer::setInitSeq方法的具体用法?C++ OutputBuffer::setInitSeq怎么用?C++ OutputBuffer::setInitSeq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputBuffer
的用法示例。
在下文中一共展示了OutputBuffer::setInitSeq方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
myreader.truncate(mybuffer.window_size());
uint16_t seq = mybuffer.retcumulative();
HeaderPacket res_pkt = mybuffer.getPkt(seq);
res_pkt.m_seq = htons(seq);
res_pkt.m_flags = htons(0x0);
cout << "Sending data packet " << seq << " retransmit " <<endl;
if(sendto(sockfd, &res_pkt, sizeof(res_pkt), 0, (struct sockaddr*) &clientAddr, clilen)<0)
{
cerr << "Sendto fails" << endl;
return 1;
}
FD_SET(sockfd, &readFds);
}
}
}
else
{
for(int fd = 0; fd <= maxSockfd; fd++){
if (FD_ISSET(fd, &readFds)) // reading, recvfrom cases
{
HeaderPacket req_pkt;
if(recvfrom(fd, &req_pkt, sizeof(req_pkt), 0, (struct sockaddr*) &clientAddr, (socklen_t*) &clilen) < 0)
{
cerr << "recvfrom failed" << endl;
return 1;
}
else
{
switch(ntohs(req_pkt.m_flags))
{
case SYNACK:
{
cout << "Receiveing SYNACK packet "<< ntohs(req_pkt.m_ack)<<endl;
mybuffer.setInitSeq(ntohs(req_pkt.m_ack));
if(myreader.hasMore())
{
mybuffer.insert(myreader.top());
myreader.pop();
}
else
{
cout <<"nomore"<<endl;
}
state = CONNECTED;
FD_CLR(fd, &readFds);
FD_SET(fd, &writeFds);
break;
}
case ACK:
{
cout << "Receiving ACK packet "<< ntohs(req_pkt.m_ack)<<endl;
mybuffer.ack(ntohs(req_pkt.m_ack));
/*
clock_t end = clock();
//reset the timeout
double sampleRTT = mybuffer.get_duration(ntohs(req_pkt.m_ack), end);
//now update the waiting time
double difference = sampleRTT - sRTT;
sRTT = sRTT + 0.125 * (difference);
devRtt = devRtt + 0.25 * (abs(difference) - devRtt);
double ret_to = sRTT + 4* devRtt;
double intpart, fracpart;