2016年4月17日 星期日

getaddrinfo

int getaddrinfo( const char* pHostName, const char* pServiceName,  const struct addrinfo* pHints,
                         struct addrinfo **pResults);

getaddrinfo() 用來取得 host 上某 service 的一系列的 IP addresses 和 port numbers。

舉例來說

struct addrinfo hints, *result;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

int error = getaddrinfo("www.kame.net", "http", &hints, &result);

沒有留言:

張貼留言