From owner-freebsd-current@FreeBSD.ORG Sun May 21 04:32:58 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DA8F016A41F; Sun, 21 May 2006 04:32:57 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from fw.zoral.com.ua (ll-227.216.82.212.sovam.net.ua [212.82.216.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id D53C443D45; Sun, 21 May 2006 04:32:56 +0000 (GMT) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by fw.zoral.com.ua (8.13.4/8.13.4) with ESMTP id k4L4WolY057743 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 21 May 2006 07:32:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.13.6/8.13.6) with ESMTP id k4L4WogN038867; Sun, 21 May 2006 07:32:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.13.6/8.13.6/Submit) id k4L4WnEM038866; Sun, 21 May 2006 07:32:49 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 21 May 2006 07:32:49 +0300 From: Kostik Belousov To: David Xu Message-ID: <20060521043249.GF54541@deviant.kiev.zoral.com.ua> References: <200605211204.10259.davidxu@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lkTb+7nhmha7W+c3" Content-Disposition: inline In-Reply-To: <200605211204.10259.davidxu@freebsd.org> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: ClamAV version 0.88.1, clamav-milter version 0.88.1 on fw.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.1.1 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on fw.zoral.com.ua Cc: current@freebsd.org Subject: Re: couldn't bind to local address X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 May 2006 04:32:58 -0000 --lkTb+7nhmha7W+c3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 21, 2006 at 12:04:10PM +0800, David Xu wrote: > It is very weired that on AMD64, bind() can not bind to local address, > the following code prints out "bind(): Can't assign requested address". >=20 > David Xu > --- >=20 >=20 > include > #include > #include >=20 > int main() > { > struct sockaddr_in addr; > int s; >=20 > s =3D socket(AF_INET, SOCK_STREAM, 0); > if (s =3D=3D -1) { > perror("socket()"); > return (1); > } >=20 > addr.sin_family =3D AF_INET; > addr.sin_port =3D htons(9000); > addr.sin_addr.s_addr =3D inet_addr("127.0.0.1"); >=20 > if (bind(s, (struct sockaddr *)&addr, sizeof(addr))) { > perror("bind()"); > return (2); > } >=20 > close(s); > return (0); > } I tried your code on the amd64% uname -a FreeBSD amd64.kiev.zoral.com.ua 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Fri May= 12 12:05:38 UTC 2006 root@:/mnt/bsd/obj/amd64/usr/bsd/src/sys/GENERIC = amd64 and did not receive any errors. Could it be that you have lo0 misconfigured= ? What ifconfig -a show ? --lkTb+7nhmha7W+c3 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (FreeBSD) iD8DBQFEb+1wC3+MBN1Mb4gRAuSiAJ9TFwqAYdDJjAJRlIWgH7wa7vKoRgCgiuMJ V19eHzIHk/pLLoO1dM2nrAY= =Rhm+ -----END PGP SIGNATURE----- --lkTb+7nhmha7W+c3--