What mode should `whois' be?

Steve D. Miller steve at mimsy.UUCP
Sat Dec 6 01:07:44 AEST 1986


AHA!  I looked at the source, and here's the *real* problem:

	struct sockaddr sin;

	sin.sin_family = AF_INET;
	if (bind(&sin, sizeof(sin)) < 0) ...

   It's not trying to bind to any particular port on the local machine;
it just wants the kernel to pick one for it.  Unfortunately, the
kernel does so only if no address is specified (all-zeroes), and this
is specifying a garbage address.

   There are two fixes:

	(1)  Remove the bind() call entirely; the connect() will
	pick a local socket automagically, as Phil Budne (budd at bu-cs)
	stated.

	(2)  stick a "bzero((char *)&sin, sizeof(sin))" just before
	the "sin.sin_family = AF_INET".  It will then bind a proper
	address, and everything will work as advertised.

   Time to send another bug report to Sun...

	-Steve
-- 
Spoken: Steve Miller 	ARPA:	steve at mimsy.umd.edu	Phone: +1-301-454-4251
CSNet:	steve at mimsy 	UUCP:	{seismo,allegra}!mimsy!steve
USPS: Computer Science Dept., University of Maryland, College Park, MD 20742



More information about the Comp.unix.wizards mailing list