Date: Sun, 21 May 2006 07:32:49 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: David Xu <davidxu@freebsd.org> Cc: current@freebsd.org Subject: Re: couldn't bind to local address Message-ID: <20060521043249.GF54541@deviant.kiev.zoral.com.ua> In-Reply-To: <200605211204.10259.davidxu@freebsd.org> References: <200605211204.10259.davidxu@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <netinet/in.h>
> #include <sys/socket.h>
> #include <stdio.h>
>=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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060521043249.GF54541>
