[comp.windows.x] X11R2/SunOS 3.2 + gethostbyname?

brad@cayman.COM (Brad Parker) (10/21/88)

Perhaps I am half a step behind the rest of the world; I was unable to
get X11R2 clients built with SunOS 3.2 to work on anything but local (unix)
sockets. They would crash in bcopy() from XConnectDisplay() if environment
variable DISPLAY was set or "-display xxx:0" was used.

I tracked it down to what looks like abberhent behavior of gethostbyname()
on Sun's. They seem to return a unsigned long IP address where other machines
return a ptr to the same. (struct hostent *)->h_addr

(I first noticed this the other day doing a gethostbyname() on a pyramid -
it returned a ptr where the sun returned an IP address)

This diff to XConnDis.c fixes it on my suns. 

185,189d184
< #ifdef SUN
< 			bcopy((char *)&host_ptr->h_addr, 
< 			      (char *)&inaddr.sin_addr, 
< 			      sizeof(inaddr.sin_addr));
< #else
193d187
< #endif

I assume everyone else in the world has figured this out by now. Perhaps
this will help some other lost sole who finally decides to upgrade from
X10R4 to X11R2 ;-)

-brad
-- 
"What will you do when you wake up one morning to find that God's made you
blind in a beautiful person's world and all those great recepies have let you
down, and you're twenty and a half and you're not getting age where you go look
for the boys 'says I love you lets get married and have kids." -Billy Bragg.

mic@ut-emx.UUCP (Mic (... K[a-z]+) Kaczmarczik) (10/22/88)

In article <1574@cayman.COM> brad@cayman.COM (Brad Parker) writes:
>Perhaps I am half a step behind the rest of the world; I was unable to
>get X11R2 clients built with SunOS 3.2 to work on anything but local (unix)
>sockets. They would crash in bcopy() from XConnectDisplay() if environment
>variable DISPLAY was set or "-display xxx:0" was used.
>
>I tracked it down to what looks like abberhent behavior of gethostbyname()
>on Sun's. They seem to return a unsigned long IP address where other machines
>return a ptr to the same. (struct hostent *)->h_addr

I don't know if this is exactly Brad's situation, but we had the same
sort of problem when we installed the Berkeley name server software on
our Suns, then later rebuilt the X library.  The clients all core
dumped just as Brad describes above, and we traced it to the version
of netdb.h we had installed as part of the nameserver installation. 

I'd check your version of netdb.h to see if it treats the h_addr field
in a hostent struct as a char * (SunOS 3.4, static host table lookup)
or a char ** (4.3 BSD, BIND name server). The netdb.h you use to
compile the clients with has to match the library you get
gethostbyname() from: if you just link against the SunOS libc.a, you
need the char * version, whereas if you see h_addr defined as a char
**, you can probably add -lresolv to the SYSAUX_LIBRARIES line in the
standard Makefiles and relink everything to get the newer
gethostbyname().

We chose to back down from the name server until we had time to
install BIND 4.8 (we were using 4.5 and having problems), so we
re-installed the old netdb.h, rebuilt XConnectDisplay, relinked the
clients, and they worked fine. 

--mic--
-- 
Mic Kaczmarczik			If you drink, don't drill.
UT Austin Computation Center			-- Matt Groening
mic@emx.utexas.edu	
MIC@UTAIVC.BITNET

guy@auspex.UUCP (Guy Harris) (10/24/88)

>I tracked it down to what looks like abberhent behavior of gethostbyname()
>on Sun's. They seem to return a unsigned long IP address where other machines
>return a ptr to the same. (struct hostent *)->h_addr

No, Sun's "gethostbyname" returns a pointer to a "struct hostent", just
as everybody else's should (and probably does).

guy@auspex.UUCP (Guy Harris) (10/24/88)

>I'd check your version of netdb.h to see if it treats the h_addr field
>in a hostent struct as a char * (SunOS 3.4, static host table lookup)
>or a char ** (4.3 BSD, BIND name server).

Or, more precisely, as a "char *" (4.2BSD) or a "char **" (4.3BSD).  The
code in the 4.3BSD <netdb.h> is:

	char	**h_addr_list;	/* list of addresses from name server */
#define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */

SunOS 4.0 has the 4.3BSD-style <netdb.h> (regardless of whether you use
-lresolv to go directly to BIND, or use the standard -lc "gethost*" to
go through "/etc/hosts" and YP and get to BIND through the YP server).