[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#564232: bind behaviour different between linux and freebsd ?



On Sat, 2010-01-09 02:50:23 +0100, Xavier Grave <grave@ipno.in2p3.fr> wrote:
> The following C code give different results on kfreebsd amd64 on one side
> and sparc/powerpc/ on the other side
> for kfreebsd amd64 :
> xavier@debian:~$ ./bind_socket_c 
> sin len 16
> res -1
> and
> for sparc :
> ./xavier@canis-latrans:~$ ./bind_socket_c 
> sin len 16
> res 0
> for powerpc :
> xavier@power5:~$ ./bind_socket_c 
> sin len 16
> res 0
> code used :
> xavier@debian:~$ cat bind_socket_c.c
> #include 
> #include 
> #include 
> 
> int main ()
> {
>  int socket_fd;
>  struct sockaddr_in sin;
>  int len,res;
> 
>  len = sizeof (struct sockaddr_in);
>  memset (&sin, 0, len);
> 
>  sin.sin_port = 5786;
> 
>  printf ("sin len %d\n",len);
>  socket_fd = socket (AF_INET,SOCK_STREAM,0);
>  res = bind (socket_fd, &sin, len);
> 
>  printf ("res %d\n",res);
> 
>  return 0;
> }
> 
> problem doesn't seem any more specific to Ada ?

`errno' should contain more detailed information about why it failed.
Also, keep in mind that "sin.sin_port = 5786" is probably not what you
want, think of network byte order! Sparc and PPC are big endian and I
guess that amd64 is little endian.

MfG, JBG

-- 
      Jan-Benedict Glaw      jbglaw@lug-owl.de              +49-172-7608481
Signature of:              What we do for ourselves dies with us. What we do for
the second  :         others and the world remains and is immortal. (Albert Pine)

Attachment: signature.asc
Description: Digital signature


Reply to: