couldn't bind to local address
John-Mark Gurney
gurney_j at resnet.uoregon.edu
Sat May 20 22:50:59 PDT 2006
David Xu wrote this message on Sun, May 21, 2006 at 12:04 +0800:
> 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".
[...]
> struct sockaddr_in addr;
[...]
> addr.sin_family = AF_INET;
> addr.sin_port = htons(9000);
> addr.sin_addr.s_addr = inet_addr("127.0.0.1");
You also forgot to initalized sin_len... I personally have adopted
the policy of using getsockaddr to initalize my addr's... that way
if sockaddr grows any additional fields, hopefully the kernel's
getsockaddr will properly fill them out for me...
--
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
More information about the freebsd-current
mailing list