fork download
  1. static int recvfrom_timeout(SOCKET sock, long sec, long usec)
  2. {
  3. struct timeval timeout;
  4. timeout.tv_sec = sec;
  5. timeout.tv_usec = usec;
  6. fd_set fds;
  7. FD_ZERO(&fds);
  8. FD_SET(sock, &fds);
  9. return select(0, &fds, 0, 0, &timeout);
  10. }
  11. void bootstrap(SOCKET sock)
  12. {
  13. char packet[PACKET_SIZE] = { 0 };
  14. size_t list_size = arr_sz(bootstrap_list);
  15. for (size_t node_idx = 0; node_idx < list_size; ++node_idx)
  16. {
  17. pull_peer_list(sock, &bootstrap_list[node_idx]);
  18. while (recvfrom_timeout(sock, 10, 0) > 0)
  19. {
  20. recvfrom(sock, packet, PACKET_SIZE, 0, NULL, NULL);
  21. client_node peer;
  22. get_data(packet, &peer);
  23. printf("recvd peer\n");
  24. show_node_data(&peer);
  25. }
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:29: error: ‘SOCKET’ was not declared in this scope
 static int recvfrom_timeout(SOCKET sock, long sec, long usec)
                             ^~~~~~
prog.cpp:1:42: error: expected primary-expression before ‘long’
 static int recvfrom_timeout(SOCKET sock, long sec, long usec)
                                          ^~~~
prog.cpp:1:52: error: expected primary-expression before ‘long’
 static int recvfrom_timeout(SOCKET sock, long sec, long usec)
                                                    ^~~~
prog.cpp:1:61: error: expression list treated as compound expression in initializer [-fpermissive]
 static int recvfrom_timeout(SOCKET sock, long sec, long usec)
                                                             ^
prog.cpp:11:16: error: variable or field ‘bootstrap’ declared void
 void bootstrap(SOCKET sock)
                ^~~~~~
prog.cpp:11:16: error: ‘SOCKET’ was not declared in this scope
stdout
Standard output is empty