Hello. It is necessary to output IP to Edit in C ++ Builder, everything works well. But the problem is that h never zero, if the computer is not online, it outputs 127.0.0.1, but I would like it to be output
ShowMessage("Вы не в сети."); Here is the code:
const int WSVer = 0x101; WSAData wsaData; hostent *h; char Buf[128]; if (WSAStartup(WSVer, &wsaData) == 0) { if (gethostname(&Buf[0], 128) == 0) { h = gethostbyname(&Buf[0]); if (h != NULL) Edit4->Text=(inet_ntoa (*(reinterpret_cast<in_addr *>(*(h->h_addr_list))))); else ShowMessage("Вы не в сети."); WSACleanup(); } } Maybe give a good link on this topic.
Thank you all in advance.