[13389] in Athena Bugs

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

sun4 7.7R: gethostbyname (expn)

daemon@ATHENA.MIT.EDU (Richard Tauriello)
Mon Apr 3 02:20:40 1995

To: bugs@MIT.EDU
Date: Mon, 03 Apr 1995 02:20:35 EDT
From: "Richard Tauriello" <rptaurie@MIT.EDU>

System name:		w20-575-24
Type and version:	SPARC/Classic 7.7R
Display type:		cgthree

		What were you trying to do?

expn (in consult) was giving me "Unknown host", which made
me think the host didn't exist, while hostinfo said 
"Cannot resolve name '%s' due to network difficulties.\n".

I noticed that expn didn't check h_errno, so I was going to make my
own version that did.  

% hostinfo megaweb.com
Cannot resolve name 'megaweb.com' due to network difficulties.

Looking at the code for hostinfo, this means h_errno was set to 2 or
3, possibly by gethostbyaddr called on the result of inet_addr (why am
I getting the feeling this is a known bug?)

		What's wrong:

This test program prints  "h_errno is 1 and should not be 1"
#include <stdio.h>
#include <netdb.h>
int main() {
  extern int h_errno;
  gethostbyname("megaweb.com");
  printf ("h_errno is %d and should not be %d\n", h_errno, HOST_NOT_FOUND);
}

(Note that megaweb.com might not be giving the same (any) error by the time
you read this)

		What should have happened:

gethostbyname should set h_errno the same way as whatever hostinfo.c
calls.  Or if someone changed expn to get around this the same way as
hostinfo and then not be misleading, that would be nice, too.

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