ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
dns.c File Reference

DNS resolution utilities implementation. More...

Go to the source code of this file.

Functions

bool dns_test_connectivity (const char *hostname)
 

Detailed Description

DNS resolution utilities implementation.

Definition in file dns.c.

Function Documentation

◆ dns_test_connectivity()

bool dns_test_connectivity ( const char *  hostname)

Definition at line 11 of file dns.c.

11 {
12 if (!hostname) {
13 log_warn("NULL hostname provided to DNS connectivity test");
14 return false;
15 }
16
17 struct addrinfo hints, *result = NULL;
18 memset(&hints, 0, sizeof(hints));
19 hints.ai_family = AF_INET; // IPv4
20 hints.ai_socktype = SOCK_STREAM;
21
22 log_debug("Testing DNS connectivity to %s...", hostname);
23
24 int ret = getaddrinfo(hostname, "443", &hints, &result);
25 if (ret != 0) {
26 log_warn("DNS resolution failed for %s: %s", hostname, gai_strerror(ret));
27 return false;
28 }
29
30 if (result) {
31 freeaddrinfo(result);
32 }
33
34 log_debug("DNS connectivity test succeeded for %s", hostname);
35 return true;
36}

Referenced by update_check_perform().