First page Back Continue Last page Overview Graphics
Example of getaddrinfo() for Servers
struct addrinfo hints, *res, *ai;
int s;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
gai = getaddrinfo(name, service, &hints, &res);
if (gai) {
printf("getaddrinfo failed: %s\n", gai_strerror(gai));
return NULL;
}
Notes: