发新话题
打印

如何得到多穴主机的多个IP地址

如何得到多穴主机的多个IP地址

  在网络中的多穴主机可能同时拥有多个IP地址,特别是在使用了动态主机地址分配时也很难知道主机上的IP地址是什么。下面我利用一段C程序来列举出主机上的所有IP地址。下面是具体代码:

void print_all_ip(void)

{

char szHostName[128];

const char* pszAddr;

struct hostent * pHost;

int i,j;

if( gethostname(szHostName, 128) == 0 )

{

pHost = gethostbyname(szHostName);

for( i = 0; pHost!= NULL

TOP

发新话题