#include <netdb.h>
#include <arpa/inet.h>
int main()
{
struct hostent *h;
char hostname[40]="publish.live2.bn.netease.com\0";
if((h=gethostbyname(hostname))==NULL)
{
fprintf(stderr,"不能得到IP\n");
exit(1);
}
printf("HostName :%s\n",h->h_name);
printf("IP Address :%s\n",inet_ntoa(*((struct in_addr *)h->h_addr)));
}
備注:如果鏈接socket時,url地址沒有指定埠號,各種協議有其默認的集中埠地址,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/153662.html
標籤:網絡通信
上一篇:WebRTC獲取指定的bmp流
