From owner-freebsd-questions@FreeBSD.ORG Tue May 1 11:02:10 2012 Return-Path: Delivered-To: freebsd-questions@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 30719106566B for ; Tue, 1 May 2012 11:02:10 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 8EB418FC1C for ; Tue, 1 May 2012 11:02:09 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [IPv6:2001:8b0:151:1:fa1e:dfff:feda:c0bb]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id q41B25aL084047 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 1 May 2012 12:02:06 +0100 (BST) (envelope-from matthew@FreeBSD.org) X-DKIM: OpenDKIM Filter v2.5.2 smtp.infracaninophile.co.uk q41B25aL084047 Authentication-Results: smtp.infracaninophile.co.uk/q41B25aL084047; dkim=none (no signature); dkim-adsp=none Message-ID: <4F9FC2AD.30905@FreeBSD.org> Date: Tue, 01 May 2012 12:02:05 +0100 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120420 Thunderbird/12.0 MIME-Version: 1.0 To: Unga References: <1335866914.5649.YahooMailNeo@web160106.mail.bf1.yahoo.com> In-Reply-To: <1335866914.5649.YahooMailNeo@web160106.mail.bf1.yahoo.com> X-Enigmail-Version: 1.4.1 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig5728715CF90556F51B1251CB" X-Virus-Scanned: clamav-milter 0.97.4 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk Cc: "freebsd-questions@freebsd.org" Subject: Re: localhost not recognised in getaddrinfo(3) in FreeBSD 9.0-STABLE X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 11:02:10 -0000 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--