Call gethostbyname with FFI?
John Clonts
jclonts at mastnet.net
Sat Feb 12 00:54:01 UTC 2000
Bert Freudenberg wrote:
>
> On Thu, 10 Feb 2000, John Clonts wrote:
>
> > Lex Spoon wrote:
> > >
> > > Of course, duh, the right thing to do is fix that primitive, not lop
> > > more code on top of it to work around it.
> >
> > I think through my inquiries here I have determined that the primitive
> > is not broken, but some nuance of my system is causing the problem
> > (though when called from a c++ prog it works ok). Thus a good exercise
> > for gee-whiz value for ffi, and if it works then it (also) buys me more
> > time till I have to upgrade my Linux version on this machine....
>
> *Please* try to modify the primitive as I suggested before. It would help
> us all and hopefully noone steps into this ever again. The change I had in
> mind is somewhat like this (in sqUnixNetwork.c):
>
> static int nameToAddr(char *hostName)
> {
> struct hostent *he;
> he = gethostbyname(hostName);
> lastError= h_errno; /* ditto */
> if (h_errno) {
> fprintf(stderr, "error: gethostbyname(%s) -> h_errno=%i\n",
> hostName, h_errno);
> herror("description");
> return 0;
> }
> return ntohl(*(long *)(he->h_addr_list[0]));
> }
>
> This should tell you what the problem is.
>
> > So, can you tell me how to specify the 'struct hostent' return value as
> > an External[Something] and thence dereference the contained char **
> > h_addr_list?
>
> I'll sent a class in a separate message.
>
> -Bert-
Hello,
I got the sources and compiled them, and the problem went away (even
before making the fix you suggested). And it of course works with the
fix, too.
I believe that the problem stems from the older-versus-newer libc
versions ( "libc5" vs "glibc6" IIRC). My system originally used the
older, but I have added the newer some months ago (successfully as far
as I knew until now...). Recompiling causes it to use libc5 and it
works like that. I'm not sure how make it link to libc6....
Thanks,
John
More information about the Squeak-dev
mailing list
|