Although we've been using getaddrinfo() in previous chapters, we'll discuss it in more detail here.
The declaration for getaddrinfo() is shown in the following code:
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
The preceding code snippet is explained as follows:
- node specifies a hostname or address as a string. Valid examples could be example.com, 192.168.1.1, or ::1.
- service specifies a service or port number as a string. Valid examples could be http or 80. Alternately, the null pointer can be passed in for service, in which case, the resulting address is set to port 0.
- hints is a pointer to a struct addrinfo, which specifies options for selecting the ...