本文整理汇总了C++中NetworkData::release方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkData::release方法的具体用法?C++ NetworkData::release怎么用?C++ NetworkData::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkData
的用法示例。
在下文中一共展示了NetworkData::release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
NetworkData* data;
IPv4Addr src("192.168.100.1"), dst("192.168.100.2");
unsigned total = 0, bad = 0;
srand48(time(0));
for (int bufsize = 0; bufsize < 10000; bufsize++) {
++total;
data = new NetworkData(bufsize);
for (int idx = 0; idx < bufsize; idx++) {
*(data->ptrBuffer() + idx) = lrand48() % 0xFF;
}
IPv4_UDP_Datagram* dgm = new IPv4_UDP_Datagram();
dgm->build(src, 4321, dst, 1234, data);
dgm->setChecksum(dgm->computeChecksum());
dgm->setUDPChecksum(dgm->computeUDPChecksum());
if ( ! dgm->hasValidUDPChecksum() ) {
++bad;
dgm->dump();
cerr << "Datagram with data field length " << bufsize << " has invalid checksum:" << endl
<< " UDPLength: " << dec << dgm->getUDPLength() << endl
<< " DataLength: " << dgm->getDataLength() << endl
<< " Stored CRC: " << hex << setw(4) << setfill('0') << dgm->getUDPChecksum() << endl
<< " Computed CRC: " << hex << setw(4) << setfill('0') << dgm->computeUDPChecksum() << endl
<< " ---------------- " << endl;
}
data->release();
dgm->release();
}
cout << "Datagrams generated: " << dec << total << endl
<< "Bad checksums: " << bad << endl;
}