#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
int getaddrinfo(const char *node, // e.g. "www.example.com" or IP
const char *service, // e.g. "http" or port number
const struct addrinfo *hints,
struct addrinfo **res);
Parameters
- The
node parameter is the host name to connect to, or an IP address.
service can be a port number, like “80”, or the name of a particular service (found in The IANA Port List21 or the /etc/services file on your Unix machine) like “http” or “ftp” or “telnet” or “smtp” or whatever.
hints parameter points to a struct addrinfo that you’ve already filled out with relevant information.