mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-01 17:36:21 +03:00
Foundation Classes - Host resolving by itself #457
Fixed issue when gethostbyname returns a nullptr, because the host can't resolve itself
This commit is contained in:
parent
e1528a3657
commit
2912b4dadb
@ -139,8 +139,13 @@ TCollection_AsciiString OSD_Host::InternetAddress()
|
||||
char buffer[16];
|
||||
TCollection_AsciiString result, host;
|
||||
|
||||
host = HostName();
|
||||
memcpy(&internet_address, gethostbyname(host.ToCString()), sizeof(struct hostent));
|
||||
host = HostName();
|
||||
const auto* aHostByName = gethostbyname(host.ToCString());
|
||||
if (aHostByName == nullptr)
|
||||
{
|
||||
aHostByName = gethostbyname("localhost");
|
||||
}
|
||||
memcpy(&internet_address, aHostByName, sizeof(struct hostent));
|
||||
|
||||
// Gets each bytes into integers
|
||||
a = (unsigned char)internet_address.h_addr_list[0][0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user