#include "ping.h" void readloop(void) { int size; char recvbuf[BUFSIZE]; socklen_t len; ssize_t n; struct timeval tval; sockfd = Socket(pr->sasend->sa_family, SOCK_RAW, pr->icmpproto); setuid(getuid()); /* don't need special permissions any more */ size = 60 * 1024; /* OK if setsockopt fails */ setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); sig_alrm(SIGALRM); /* send first packet */ for ( ; ; ) { len = pr->salen; n = recvfrom(sockfd, recvbuf, sizeof(recvbuf), 0, pr->sarecv, &len); if (n < 0) { if (errno == EINTR) continue; else err_sys("recvfrom error"); } Gettimeofday(&tval, NULL); (*pr->fproc)(recvbuf, n, &tval); } }