INADDR_ANY, sin_family
Brain in Neutral
bin at primate.wisc.edu
Tue Aug 1 02:10:45 AEST 1989
1) Given
struct sockaddr_in sin;
which of the following is more proper?
sin.sin_addr.s_addr = INADDR_ANY;
or
sin.sin_addr.s_addr = htonl (INADDR_ANY);
Yes, I know INADDR_ANY is zero. I ask for purposes of stylistic correctness.
Is INADDR_ANY considered to be in host or network order? The BSD Advanced
IPC manual uses htonl (INADDR_ANY) in its examples, but some of the BSD
source (e.g., for rresvport()), uses plain INADDR_ANY.
2) If sin.sin_family is zero when &sin is passed to a call to bind(), is
the family chosen to be the one that was specified when the bound socket
was created? For example, inetd does not appear to fill in the sin_family
field (leaves it zero = AF_UNSPEC), yet the bind calls succeed.
Paul DuBois
dubois at primate.wisc.edu
More information about the Comp.unix.wizards
mailing list