On Tue, May 12, 2009 at 09:41:53AM -0400, Dan Winship wrote: > On 05/12/2009 05:22 AM, Paul LeoNerd Evans wrote: > > Speaking of GResolver, in the API (which I'm currently staring at here: > > > > http://git.gnome.org/cgit/glib/diff/gio/gresolver.h?h=gresolver&id=05507dce1f540581028e8be0e220e68c44fade2f > > > > ) I don't see any attempt at the gai()-style "hostname + servicename" > > resolver. Where's the ability to connect to, say, "www.google.com:http"? > > > > Half the point of gai+gni was to unify the separate operations of > > hostname->IP and servicename->port, so they're in one combined place. > > gai() can therefore support things like SRV records, which the previous > > pair of gethostbyname+getservbyname cannot. > > You're mixing up two very different things. getaddrinfo *does not* use > SRV records. When you pass a (non-numeric) string to getaddrinfo for > "service", it just looks that string up in /etc/services to translate it > to a port number, and returns that port number (regardless of whether or > not that service is really running on the host). Ah; I wasn't quite clear enough in my statement. I didn't mean that e.g. GNU libc's _implementation_ of getaddrinfo() currently today actually does a SRV lookup, merely the RFC 2553 _interface_ which defines getaddrinfo() has to hand all the information that such a lookup would require, so an implementation can, in theory, do it. > GResolver intentionally does not support doing the servicename->port > mapping thing that getaddrinfo/getsrvbyname does though, because it's a > bad API; you can't know for sure what's going to be in /etc/services on > any given machine, and in particular, if you're using some very new > protocol, it's very likely that some people are going to try to run your > application on machines that don't have that protocol listed in > /etc/services. So it's always better to just provide your own #define > FOOBAR_PORT with the right port number, and then use that, rather than > crossing your fingers and hoping that GResolver will be able to map > "foobar" to the right number for you. Hmm.. I guess that's fair enough then I suppose; though surely that's not a reason not to provide the _ability_ to do so, simply a discouragement for applications developers to try to actually make use of it, in this manner..? -- Paul "LeoNerd" Evans leonerd leonerd org uk ICQ# 4135350 | Registered Linux# 179460 http://www.leonerd.org.uk/
Attachment:
signature.asc
Description: Digital signature