摘要: 1. 使用getaddrinfo获取主机IP,这种方法受系统,hostname与IP的绑定配置有关,最后不要用localhost,一般localhost配置的IP为127.0.0.1 另一种方法是使用getifaddress,没用过int getIP(char *host, char *buf, int size){ assert(host != NULL && buf != NULL); struct addrinfo hints; struct addrinfo *result, *rp; int s, sfd; memset(&hints, 0, sizeof(s 阅读全文
posted @ 2013-07-16 08:27 D3猎人 阅读(265) 评论(0) 推荐(0) 编辑