Home > Back-end >  Rescue a great god!!!!!!!!!! Through the IP access to equipment name within a local area network (LA
Rescue a great god!!!!!!!!!! Through the IP access to equipment name within a local area network (LA

Time:12-04

Rescue a great god!!!!!!!!!! Through the IP access to equipment name within a local area network (LAN) function gethostbyaddr () returns all bogon, what to do!!

CodePudding user response:

Post code, map

CodePudding user response:

WSAData WSAData;
WSAStartup (MAKEWORD (2, 0), & amp; WsaData);

Char ipp [4].

Ipp [0]=192;
Ipp [1]=168;
Ipp [2]=0;
Ipp [3]=100;




HOSTENT * lpHostEnt;

In_addr ina;



LpHostEnt=gethostbyaddr (ipp, sizeof (ipp), AF_INET);





ShowMessage (lpHostEnt - & gt; H_name);//display the host name


WSACleanup ();


Including 192.168.0.100 is the machine's IP, this return "" bogon" "

But if change the IP to 127.0.0.1 can return the machine name correctly,,

CodePudding user response:

Run with administrator try it?
  • Related