First page Back Continue Last page Overview Graphics
Example of getaddrinfo() for Servers (cont'ed)
for (ai = res; ai != NULL; ai = ai->ai_next) {
s = socket(ai->ai_family, ai->ai_socktype,
ai->ai_protocol);
if (s < 0) continue;
if (bind(s, ai->ai_addr, ai->ai_addrlen) < 0) {
close(s);
s = -1;
continue;
}
break;
}
freeaddrinfo(res);
Notes: