69,382
社区成员
发帖
与我相关
我的任务
分享
rc = gethostname(hname, sizeof(hname));
if (rc == -1) {
printf("%s: failed in gethostname,lien=%d,%s\n", __FUNCTION__, __LINE__, strerror(errno));
return -1;
}
printf("hostname is %s\n", hname);
ht = gethostbyname(hname);
if (ht == NULL) {
printf("%s: failed in gethostbyname,line=%d,%s\n", __FUNCTION__, __LINE__, strerror(h_errno));
return -1;
}