| 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 | { |