HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 108
Print out response.
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 108 highlights
Using Internet Datagram Sockets Example Using Datagram Sockets if (recv (s, &reqaddr, sizeof(struct in_addr), 0) == -1) { if (errno == EINTR) { /* Alarm went off & aborted the receive. * Need to retry the request if we have * not already exceeded the retry limit. */ if (-retry) { goto again; } else { printf("Unable to get response from"); printf(" %s after %d attempts.\n", argv[1], RETRIES); exit(1); } } else { perror(argv[0]); fprintf(stderr, "%s: unable to receive response\n", argv[0]); exit(1); } } alarm(0); /* Print out response. */ if (reqaddr.s_addr == ADDRNOTFOUND) { printf("Host %s unknown by nameserver %s.\n", argv[2], argv[1]); exit(1); } else { printf("Address for %s is %s.\n", argv[2], inet_ntoa(reqaddr)); } } 108 Chapter 4
108
Chapter 4
Using Internet Datagram Sockets
Example Using Datagram Sockets
if (recv (s, &reqaddr, sizeof(struct in_addr), 0) == -1) {
if (errno == EINTR) {
/* Alarm went off & aborted the receive.
* Need to retry the request if we have
* not already exceeded the retry limit.
*/
if (—retry) {
goto again;
} else {
printf(”Unable to get response from”);
printf(” %s after %d attempts.\n”,
argv[1], RETRIES);
exit(1);
}
} else {
perror(argv[0]);
fprintf(stderr, ”%s: unable to receive response\n”,
argv[0]);
exit(1);
}
}
alarm(0);
/* Print out response. */
if (reqaddr.s_addr == ADDRNOTFOUND) {
printf(”Host %s unknown by nameserver %s.\n”, argv[2],
argv[1]);
exit(1);
} else {
printf(”Address for %s is %s.\n”, argv[2],
inet_ntoa(reqaddr));
}
}