本文整理汇总了C++中Counter::check方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::check方法的具体用法?C++ Counter::check怎么用?C++ Counter::check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter::check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
printf("Emulator polling on port %d\n\n", port);
fflush(stdout);
RoutePacket recv_packet;
RoutePacket send_packet;
Packet ping_packet;
send_packet.type() = 'R';
send_packet.TTL() = START_TTL;
send_packet.set_source(emulator_address);
ping_packet.type() = 'P';
ping_packet.TTL() = 2;
ping_packet.set_source(emulator_address);
Counter c;
unsigned int seq_no = 0;
// flag that says routing table needs to be updated
bool dirty_routing_table = false;
Address current_hop_address;
std::vector<Address> other_hops_vector;
int send_sock;
// Setup port to send on
if ((send_sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
{
perror("Socket");
exit(1);
}
while (1)
{
switch (c.check())
{
case PING:
{
std::vector<Address> port_addresses = graph_manager.get_port_addresses();
for (unsigned int i = 0; i < port_addresses.size(); ++i)
{
// Send to next shortest path
next_addr.sin_family = AF_INET;
next_addr.sin_port = port_addresses[i].second;
next_addr.sin_addr.s_addr = port_addresses[i].first;
bzero(&(next_addr.sin_zero), 8);
ping_packet.set_destination(port_addresses[i]);
sendto(send_sock, ping_packet, HEADER_LENGTH, 0,
(struct sockaddr *) &next_addr, sizeof(struct sockaddr));
if (0 && debug)
{
printf("sending packet:\n");
ping_packet.print();
printf("actual destination: %lu %u (%s %u)\n\n",
next_addr.sin_addr.s_addr,
next_addr.sin_port,
inet_ntoa(next_addr.sin_addr),
ntohs(next_addr.sin_port));
fflush(stdout);
}
}
break;
}