Hacker News new | ask | show | jobs
by ericyan 1207 days ago
RFC 7766 [1] actually requires TCP support:

> Section 6.1.3.2 of [RFC1123] is updated: All general-purpose DNS implementations MUST support both UDP and TCP transport.

For stub resolvers like the ones provided by glibc and musl:

> Stub resolver implementations (e.g., an operating system's DNS resolution library) MUST support TCP since to do otherwise would limit the interoperability between their own clients and upstream servers.

[1]: https://datatracker.ietf.org/doc/html/rfc7766#section-5

1 comments

`getaddrinfo` is a POSIX function, and the POSIX specification for it[1] allows implementations that only support UDP (it even allows implementations that don't use DNS). Such implementations should (but are not required to) set the `struct addrinfo` `hints` field to `IPPROTO_UDP`. Note that POSIX only mentions "In many cases it is implemented by the Domain Name System, as documented in RFC 1034, RFC 1035, and RFC 1886." and not any later RFCs, so RFC 7766 changes aren't required for POSIX-compliant implementations.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/