On Sat, 2010-01-09 14:37:58 +0100, Xavier Grave <gr...@ipno.in2p3.fr> wrote: > >> sin.sin_port = 5786; > > > `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. > > changing > sin.sin_port = 5786; > to > sin.sin_port = htons (5786); > doesn't change results on kfreebsd amd64 arch
Did you test errno? Please try this: #include <errno.h> #include <stdio.h> #include <string.h> #include <netinet/in.h> #include <sys/socket.h> int main (int argc, char *argv[]) { int socket_fd; struct sockaddr_in sin; int len, res; len = sizeof (struct sockaddr_in); memset (&sin, 0, len); sin.sin_port = htons (5786); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; printf ("sin len %d\n",len); socket_fd = socket (AF_INET,SOCK_STREAM,0); res = bind (socket_fd, (struct sockaddr *) &sin, len); printf ("res = %d, errno = %s\n", res, strerror (res? errno: 0)); return 0; } MfG, JBG -- Jan-Benedict Glaw jbg...@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)
signature.asc
Description: Digital signature