本文整理汇总了C++中OutputBuffer::getNextSeqNo方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputBuffer::getNextSeqNo方法的具体用法?C++ OutputBuffer::getNextSeqNo怎么用?C++ OutputBuffer::getNextSeqNo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputBuffer
的用法示例。
在下文中一共展示了OutputBuffer::getNextSeqNo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
double devRtt = 3;
struct timeval tv;
if(!FD_ISSET(sockfd, &readFds))
FD_SET(sockfd, &readFds);
while (true) {
int nReadyFds = 0;
errFds = watchFds;
if(!FD_ISSET(sockfd, &watchFds))
FD_SET(sockfd, &watchFds);
tv.tv_sec = 0;
tv.tv_usec = 500000;
if(finish)
{
cout << "Time to close the connection"<<endl;
//close(sockfd);
break;
}
if ((nReadyFds = select(maxSockfd+1, &readFds, &writeFds, &errFds, &tv)) == -1) {
perror("select");
return 4;
}
if (nReadyFds == 0) {
cout << "TIMEOUT HAPPENS" <<endl;
if(state == SYNACK_SENT)
{
HeaderPacket resp_pkt_synack;
uint16_t seq = mybuffer.getNextSeqNo();
cout << "Send out SYNACK packet "<< seq << "Retransmit "<<endl;
resp_pkt_synack.m_seq = htons(seq);
resp_pkt_synack.m_ack = htons(0);
resp_pkt_synack.m_flags = htons(SYNACK); //SYNACK flag
//resp_pkt_synack.m_window = htons(mybuffer.getWindowSize());
if(sendto(sockfd, &resp_pkt_synack, sizeof(resp_pkt_synack), 0, (struct sockaddr*) &clientAddr, clilen)<0)
{
cerr << "Sendto fails" << endl;
return 1;
}
FD_SET(sockfd, &readFds);
}
else if (state == SENT_FIN)
{
HeaderPacket resp_pkt_fin;
resp_pkt_fin.m_seq = htons(mybuffer.getNextSeqNo());
resp_pkt_fin.m_flags = htons(FIN); //FIN flag
resp_pkt_fin.m_ack = htons(0);
//resp_pkt_fin.m_window = htons(mybuffer.getWindowSize());
if(sendto(sockfd, &resp_pkt_fin, sizeof(resp_pkt_fin), 0, (struct sockaddr*) &clientAddr, clilen)<0)
{
cerr << "Sendto fails" << endl;
return 1;
}
FD_SET(sockfd, &readFds);
}
else if (state == CONNECTED)
{
if(mybuffer.timeout())
{