MCPcopy Create free account
hub / github.com/defold/defold / AddressToIPString

Function AddressToIPString

engine/dlib/src/dlib/socket_posix.cpp:733–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

731 }
732
733 char* AddressToIPString(Address address)
734 {
735 if (address.m_family == dmSocket::DOMAIN_IPV4)
736 {
737 // Maximum length of an IPv4 address is 15 characters.
738 // 255.255.255.255
739 char addrstr[15 + 1] = { 0 };
740 inet_ntop(AF_INET, IPv4(&address), addrstr, sizeof(addrstr));
741 return strdup(addrstr);
742 }
743 else if (address.m_family == dmSocket::DOMAIN_IPV6)
744 {
745 // Maximum (theoretical) length of an IPv6 address is 45 characters.
746 // ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255
747 char addrstr[45 + 1] = { 0 };
748 inet_ntop(AF_INET6, IPv6(&address), addrstr, sizeof(addrstr));
749 return strdup(addrstr);
750 }
751 else
752 {
753 dmLogError("Failed to convert address from binary, unsupported address family!");
754 return 0x0;
755 }
756 }
757
758 Result GetHostByName(const char* name, Address* address, bool ipv4, bool ipv6)
759 {

Callers

nothing calls this directly

Calls 2

IPv4Function · 0.85
IPv6Function · 0.85

Tested by

no test coverage detected