// get the name of the local host
if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) {
printf("Error getting local host name: %d\n",WSAGetLastError());
return 1;
}
printf("Host name is %s\n",ac);
phe = gethostbyname(ac);
if (phe == 0) {
cerr << "Error: Bad host lookup." << endl;
return 1;
}
for (i=0; phe->h_addr_list !=0; ++i) {
memcpy(&addr, phe->h_addr_list,sizeof(struct in_addr));
printf("Card %i) %s\n",i,inet_ntoa(addr));
local=inet_ntoa(addr);
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.