# Include <winsock2.h># PragmaComment (Lib, "ws2_32 ")
Wsadata; Int Wsareturn; Char Name [ 20 ]; Struct Hostent * Psysinfo; Char Ipaddr [ 20 ]; Wsareturn = Wsastartup (makeword (2 , 2 ),& Wsadata ); If (Wsareturn = 0 ) {Gethostname (name, 20 ); // Obtain the local host name m_strhostname = Name; // Updatedata (false ); Psysinfo = Gethostbyname (name); sprintf (ipaddr, " % D. % d " , Psysinfo -> H_addr_list [ 0 ] [ 0 ] & 0x00ff , Psysinfo -> H_addr_list [ 0 ] [ 1 ] & 0x00ff , Psysinfo -> H_addr_list [ 0 ] [ 2 ] &0x00ff , Psysinfo -> H_addr_list [ 0 ] [ 3 ] & 0x00ff ); M_strip = Ipaddr; updatedata (false );}
You can use the gethostbyaddr function to send the network address to get the corresponding "host". Here, the host may be multiple but more than one
StructHostent *Far gethostbyaddr {Const Char* ADDR;//<Input> pointer to the network byte sequential addressIntLen;//Address LengthIntType;//Address type, which must be af_inet};