本文整理汇总了C++中Frame::GetNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ Frame::GetNumber方法的具体用法?C++ Frame::GetNumber怎么用?C++ Frame::GetNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame::GetNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threadParent
void* threadParent(void *arg) {
/* Parent Thread */
char* chck;
/* Ketika belum diterima End Of Frame,
teruskan listening untuk penerimaan byte */
while ( (parentExit != 1) ) {
chck = rcvchar(sockfd, &buffer);
if ( chck != NULL ) {
Frame F;
F.GetDecompiled(chck);
if ( (F.GetMessage()).at(0) != 26 ) {
printf("Menerima Frame ke-%d\n", F.GetNumber());
} else {
printf("EOF diterima\n");
getEOF = F.GetNumber();
}
}
}
printf("Exiting Child\n");
return NULL;
}
示例2: threadChild
void* threadChild(void *arg) {
/* Child Thread */
char* chck;
int i = 0;
int length = 0;
int start = 0;
bool canBeConsumed = false;
Frame Ftemp[100];
int temp[100];
int tempLength = 0;
/* Sampai program diakhiri, konsumsi terus byte yang ada pada buffer*/
while (parentExit != 1) {
chck = q_get(sockfd, &buffer);
if ( chck != NULL ) {
Frame F;
F.GetDecompiled(chck);
// Set frame number dan checksum pada Response
R.SetNumber(F.GetNumber());
R.SetChecksum(F.GetChecksum());
// Checks checksum
cout << F.GenerateChecksumCRC(chck) << endl;
cout << F.GetChecksum() << endl;
if ( F.GenerateChecksumCRC(chck) != F.GetChecksum() ) {
printf("Invalid Checksum. Send NAK.\n");
R.SetType(NAK);
--receivedByte;
} else {
R.SetType(ACK);
}
int num = R.GetNumber();
if (tempLength < ( R.GetNumber() + 1 )) {
tempLength = R.GetNumber() + 1;
}
if (R.GetType() == ACK)
{
if (num < i)
{
temp[num] = num;
Ftemp[num] = F;
}
else {
temp[i] = i;
Ftemp[i] = F;
if ( i > 0 ) { length++; }
}
}
else {
//NAK
if (num < i)
temp[num] = -1;
else
temp[i] = -1;
}
int j = Rw.getLength();
while ( ( temp[j] != -1 ) && ( j < tempLength ) ) {
Rw.insertFrame(Ftemp[j], j);
cout << "Mengkonsumsi frame ke-" << j << " [" << Rw.getFrame(j).GetMessage() << "] Mencoba mengirim ACK" << endl;
++consumedByte;
Rw.slideWindow();
++j;
}
i++;
sprintf(res, "%s", (R.GetCompiled()).c_str());
if (sendto(sockfd, res, MaxResponseLength, 0, (struct sockaddr *)&targetAddr, addrLen) == -1) {
perror("sendto");
}
if ( ( getEOF != 0 ) && ( (getEOF + 1) == consumedByte ) ) {
parentExit = 1;
}
}
}
Rw.iterateFrames();
printf("Exiting Parent\n");
return NULL;
}