Re: getnameinfo() and sa_len

From: YOSHIFUJI Hideaki / 吉藤英明
Date: Thu Feb 19 2004 - 09:48:06 EST


In article <00ae01c3f6f2$0021a7b0$210d640a@xxxxxxxxx> (at Thu, 19 Feb 2004 15:09:32 +0100), "Jeroen Massar" <jeroen@xxxxxxxxx> says:

> A small google on getnameinfo() and sa_len produced that
> Linux apparently doesn't have any sa_len field in the sockaddr
> structures, while every other OS (including your beloved Windows ;)
> and the various BSD's have it, apparently it is 'optional', but
> from the EXAMPLES section on a Debian unstable's getnameinfo(3) page:

I don't think Windows, Solaris, AIX , HP/UX, Irix, Tru64 ...
(not in particular order) has sa_len field in the sockaddr{}.

> struct sockaddr *sa; /* input */
> char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
>
> if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf,
> sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
> printf("host=%s, serv=%s\n", hbuf, sbuf);
:
> So what is up with the documentation, or better, how can I as an
> application programmer get a valid sa_len for getnameinfo() ? :)

Well, the style of this code is not good.
Salen should be given to this "function."
(Or you've got via 3rd argument of get{sock,peer}name()).

--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@xxxxxxxxxxxxxx>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html