[410] in Hesiod

home help back first fref pref prev next nref lref last post

Re: Question re: port number in hesservbyname.c

daemon@ATHENA.MIT.EDU (Greg Hudson)
Tue Apr 24 00:20:23 2001

Message-Id: <200104240419.AAA13238@equal-rites.mit.edu>
To: "Thomas M. Payerle" <payerle@phys-mail1.physics.umd.edu>
cc: hesiod@MIT.EDU, payerle@physics.umd.edu
In-Reply-To: Your message of "Mon, 23 Apr 2001 17:25:01 EDT."
             <200104232125.RAA03002@bofh.physics.umd.edu> 
Date: Tue, 24 Apr 2001 00:19:06 -0400
From: Greg Hudson <ghudson@MIT.EDU>

> Why do you have the htons call to translate to network byte order?

It's what getservbyname() does.

> Presumably, any system calls spitting the port number back out onto
> the net will take care of converting from local to network byte
> order, so I would think the htons is erroneous.

You'd think so, but as it turns out, the Unix servent/hostent/sockaddr
structures store addresses and ports in network byte order.  Saves a
few instructions in the path of the network code, I guess.  Fairly
ludicrous in today's world, but there you have it.

> (and if so, the man pages should clearly say so).

Currently, the hesiod_getservbyname man page just references the
getservbyname man page; given that decision, I don't think it's really
the business of the hesiod_getservbyname man page to point out
non-obvious characteristics of the servent structure.

home help back first fref pref prev next nref lref last post