Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!batcomputer!cornell!uw-beaver!mit-eddie!bbn.com!pplacewa From: pplacewa@bbn.com (Paul W Placeway) Newsgroups: comp.sys.sgi Subject: What do I have to do to get gethostbyaddr to work? Message-ID: <63465@bbn.BBN.COM> Date: 30 Mar 91 00:01:25 GMT Sender: news@bbn.com Distribution: comp Lines: 50 I'm stumped. I can't seem to make gethostbyaddr to work right. The host is in /etc/hosts (which shouldn't even exist, but that's another issue), AND it's in the YP version of hosts ("ypmatch hosts.byaddr" works), AND the DNS knows about it. I've tried compiling this tidbit normally, with -D_BSD_COMPAT and -lbsd, and with -D_BSD_COMPAT, -lsun -lbsd (to get YP stuff). None of them work. It works fine on our Suns. This is on a 4d/240 running Irix 3.3.2. -- Paul Placeway ================ cut here ================ #! /bin/sh # To extract, remove mail header lines and type "sh filename" echo x - FOO.c sed -e 's/^X//' > FOO.c << '!FaR!OuT!' X#include X#include X#include X#include X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X struct hostent *h; X char *host_addr; X long l; X X if (sscanf(argv[1], "%ld", &l) != 1) X exit (1); X X host_addr = (char *) &l; X h = gethostbyaddr (host_addr, sizeof (long), 0); X if (h == (struct hostent *) 0) { X#ifdef sun X printf("h_errno == %d\n", h_errno); X#else X herror("gethostbyaddr"); X#endif X } else { X printf("%s\n", h->h_name); X } X X exit (0); X} X !FaR!OuT! exit