1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

Make the example a bit more pretty.

This commit is contained in:
Pawel Jakub Dawidek 2012-09-22 17:46:53 +00:00
parent 81c4584e30
commit 3ee8189de1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=240832

View File

@ -570,7 +570,8 @@ struct iovec iov[2];
u_char buf[BUFSIZ];
struct cmsghdr *cm;
struct msghdr m;
int found, optval;
int optval;
bool found;
u_char data[2048];
/* Create socket. */
@ -597,8 +598,8 @@ if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPLIMIT, &optval,
sizeof(optval)) == -1)
err(1, "setsockopt");
found = 0;
while (!found) {
found = false;
do {
if (recvmsg(s, &m, 0) == -1)
err(1, "recvmsg");
for (cm = CMSG_FIRSTHDR(&m); cm != NULL;
@ -606,13 +607,13 @@ while (!found) {
if (cm->cmsg_level == IPPROTO_IPV6 &&
cm->cmsg_type == IPV6_HOPLIMIT &&
cm->cmsg_len == CMSG_LEN(sizeof(int))) {
found = 1;
found = true;
(void)printf("hop limit: %d\en",
*(int *)CMSG_DATA(cm));
break;
}
}
}
} while (!found);
.Ed
.Sh DIAGNOSTICS
A socket operation may fail with one of the following errors returned: