Skip to content

dns: Return all kinds of socket types available

Ander Juaristi requested to merge aj-dns-socktype into master

The resolve() function would always return SOCK_STREAM-type sockets, TCP sockets.

I propose to change this function such that it will return all the socket types that the system supports (by removing the .ai_socktype = SOCK_STREAM hint), and then let the consumer decide which socket type they want to use.

These changes will be needed for the upcoming QUIC+HTTP/3 code, which is based entirely on UDP.

My biggest concern is that wget_dns_resolve is a public API function and we are changing its behavior here. Although we never documented this function will always return TCP sockets, folks out there might have relied on that behavior. I have observed my getaddrinfo() always puts the SOCK_STREAM sockets first on the returned addrinfo list, but I don't know if this is intentional or not. And in any case, not sensible to rely on.

Another possibility would be to maintain the current wget_dns_resolve behavior (always returning TCP sockets), and create a new function (let's say wget_dns_resolve2) that lets the caller decide which socket type they want.

In addition, I'm introducing other subtle changes such as moving TCP connect code to its own function to declutter some of the code.

Approver's checklist:

  • The author has submitted the FSF Copyright Assignment and is listed in AUTHORS
  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent with existing code
  • This feature/change has adequate documentation added (if appropriate)
  • No obvious mistakes / misspelling in the code
Edited by Tim Rühsen

Merge request reports