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

Function GetLocalAddress

engine/dlib/src/dlib/socket_win32.cpp:663–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

661 }
662
663 Result GetLocalAddress(Address* address)
664 {
665 /*
666 * Get local address from reverse lookup of hostname
667 * The method is potentially fragile. On iOS we iterate
668 * over network adapter to the find actual address for en0
669 * See socket_apple.mm
670 */
671 char hostname[256] = { 0 };
672 Result r = dmSocket::GetHostname(hostname, sizeof(hostname));
673 if (r != dmSocket::RESULT_OK)
674 return r;
675
676 r = dmSocket::GetHostByName(hostname, address);
677 if (r != RESULT_OK)
678 {
679 dmSocket::GetHostByName("localhost", address);
680 static bool warning_emitted = false;
681 if (!warning_emitted)
682 {
683 dmLogWarning("No IP found for local hostname %s. Fallbacks to localhost", hostname);
684 }
685 warning_emitted = true;
686 }
687
688 return RESULT_OK;
689 }
690
691 Result SetBlocking(Socket socket, bool blocking)
692 {

Callers 4

NewFunction · 0.70
SetupMulticastCaptureFunction · 0.50
InitMethod · 0.50

Calls 2

GetHostnameFunction · 0.70
GetHostByNameFunction · 0.70

Tested by 2

SetupMulticastCaptureFunction · 0.40