Date: Tue, 01 May 2012 12:02:05 +0100 From: Matthew Seaman <matthew@FreeBSD.org> To: Unga <unga888@yahoo.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@FreeBSD.org> Subject: Re: localhost not recognised in getaddrinfo(3) in FreeBSD 9.0-STABLE Message-ID: <4F9FC2AD.30905@FreeBSD.org> In-Reply-To: <1335866914.5649.YahooMailNeo@web160106.mail.bf1.yahoo.com> References: <1335866914.5649.YahooMailNeo@web160106.mail.bf1.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5728715CF90556F51B1251CB Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 01/05/2012 11:08, Unga wrote: > Following code fragment works in FreeBSD 8.1-RELEASE, but not in FreeBS= D 9.0-STABLE: >=20 > error =3D getaddrinfo("localhost", port, &hints, &res0); > if (error) > { > fprintf(stderr,"getaddrinfo failed - %s\n", gai_strerror(error)); > exit(1); > } >=20 > It complains: getaddrinfo failed - hostname nor servname provided, or n= ot known >=20 > Any idea why? >=20 So, what is the variable 'port' initialized to? It should be a const char* with the name of a network service found in /etc/services or else the string representation of a port number in decimal. Failing that, this is almost certainly a configuration snafu on your 9.0-STABLE box. Does this machine have an entry for localhost in /etc/hosts ? Can it resolve localhost via the DNS? Or through any other means such as NIS or LDAP? What does: % getent hosts localhost return? If that fails, sanity check /etc/nsswitch.conf and /etc/resolv.conf Cheers, Matthew=09 --=20 Dr Matthew J Seaman MA, D.Phil. PGP: http://www.infracaninophile.co.uk/pgpkey --------------enig5728715CF90556F51B1251CB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+fwq0ACgkQ8Mjk52CukIwfrgCbBAvXMFkVBo1Q6W6cRMimNhgB FmgAn0cjgIzW1l8SqV5ZGjoYPqG2+nky =aT6z -----END PGP SIGNATURE----- --------------enig5728715CF90556F51B1251CB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F9FC2AD.30905>