ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
dns.c
Go to the documentation of this file.
1
6#include <ascii-chat/network/dns.h>
7#include <ascii-chat/platform/network.h>
8#include <ascii-chat/log/logging.h>
9#include <string.h>
10
11bool dns_test_connectivity(const char *hostname) {
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}
bool dns_test_connectivity(const char *hostname)
Definition dns.c:11