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

Function AddressToIPString

engine/dlib/src/dlib/socket_win32.cpp:753–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

751 }
752
753 char* AddressToIPString(Address address)
754 {
755 if (address.m_family == dmSocket::DOMAIN_IPV4)
756 {
757 // Maximum length of an IPv4 address is 15 characters.
758 // 255.255.255.255
759 char addrstr[15 + 1] = { 0 };
760 inet_ntop(AF_INET, IPv4(&address), addrstr, sizeof(addrstr));
761 return strdup(addrstr);
762 }
763 else if (address.m_family == dmSocket::DOMAIN_IPV6)
764 {
765 // Maximum (theoretical) length of an IPv6 address is 45 characters.
766 // ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255
767 char addrstr[45 + 1] = { 0 };
768 inet_ntop(AF_INET6, IPv6(&address), addrstr, sizeof(addrstr));
769 return strdup(addrstr);
770 }
771 else
772 {
773 dmLogError("Failed to convert address from binary, unsupported address family!");
774 return 0x0;
775 }
776 }
777
778 Result GetHostByName(const char* name, Address* address, bool ipv4, bool ipv6)
779 {

Callers 3

Sys_GetIfaddrsFunction · 0.50
TESTFunction · 0.50
InitMethod · 0.50

Calls 2

IPv4Function · 0.85
IPv6Function · 0.85

Tested by 1

TESTFunction · 0.40