Advertisement
zinosat

poll

Jan 25th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. int wait_for_incoming_packet = 0; /* 1:block, 0:non blocking */
  2.  
  3. rv = pfring_recv(ring, &b, 0, &h, wait_for_incoming_packet);
  4. if (rv < 0)
  5. return -1;
  6.  
  7. if (rv == 0)
  8. {
  9. pfd.fd = pfring_get_selectable_fd(ring);
  10. pfd.events = POLLIN;
  11. pfd.revents = 0;
  12.  
  13. rc = poll(&pfd, 1, ACK_FROM_NV_TIMEOUT);
  14.  
  15. if (rc > 0) {
  16. rv = pfring_recv(ring, &b, 0, &h, wait_for_incoming_packet);
  17.  
  18. /* pfring_recv() ritorna success */
  19. if (rv == 1) {
  20. if (b[42] != chunk_nr) {
  21. printf("-3\n");
  22. return -3; /* non era ACK */
  23. }
  24. else
  25. return 0; /* OK - ACK ricevuto */
  26. }
  27. }
  28.  
  29. if (rc == 0) /* timeout */
  30. {
  31. printf("-2\n");
  32. return -2;
  33. }
  34.  
  35. if (rc < 0) {
  36. printf("-1\n");
  37. return -1; /* errore ritornato da pfring_recv() */
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement