[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: getaddrinfo: how to wildcard everything?
Date: Thu, 18 Mar 2021 11:39:38 -0400 (EDT)
From: Mouse <mouse%Rodents-Montreal.ORG@localhost>
I have seen no replies to your message, so ...
| So I'm wondering if anyone here has enough insight into the design
| decisions behind getaddrinfo() to know what the designer(s) intended
| people use to do what I'm trying to do here: bind a port-0 (or moral
| equivalent) socket in each supported address family.
I am not going to claim to any particular insight, but I suspect that
the mindset might have been that there were a few uses for getaddrinfo()
imagined, but enumerating address families was not one of them.
I'm not sure it is worth it either ... there are just 2 (IPv4 and IPv6)
and if a new one were added, any code written to deal with those two would
need to be modified to handle something different, almost certainly.
So, in practice, no-one wants to look up nothing, just to find out what
address families exist (if an implementation doesn't support one of the
two, you'd discover that on attempted use).
But for a hackish kind of solution to your problem, nothing says that you
are required to use the address structures returned from getaddrinfo()
unaltered - they're not opaque. So, you can just look for some random
well known service (telnet, ftp, http, echo, ...) and when you get the
results back, simply overwrite the port number field with the 0 you wanted
to get returned.
You could also just try "0" as the service name, though I'm not sure how
portable that would be, if it works.
Main Index |
Thread Index |