Menu

bind failed under FreeBSD 4.2

Help
2000-12-19
2000-12-20
  • Maxim F. Ischenko

    While trying to run demo programs under

    FreeBSD 4.2 (CommonC++ version 1.2.5.1 and 1.2.6)

    got this errors:

    $ ./tcp

    testing addr: 255.255.255.255:4096

    binding for: 127.0.0.1:4096

    127.0.0.1   4096

    socket error 0.0.0.0:0

    error number 5

    bind failed; no resources

    $ ./tcpthread

    testing addr: 255.255.255.255:4096

    binding for: localhost:4096

    127.0.0.1   4096

    socket error (null):0 = 16

    bind failed; port busy

    Why is this and what can I do to fix it?

     
    • David Sugar

      David Sugar - 2000-12-20

      I was about to do some FreeBSD testing again...no, that should not happen, unless the "bind" calls in socket.cpp are returing an error status.  Since 4096 is not a priviledged port range, it shouldn't be a problem, unless there is some other process on your machine using that port number.

       
      • Maxim F. Ischenko

        I'm absolutely sure that no other process holds the port. I've tried several different ports with  the same result.

        May be ktrace output will be helpful for you.

          1265 svd      CALL  socket(0x2,0x1,0)

          1265 svd      RET   socket 5

          1265 svd      CALL  fcntl(0x5,0x3,0)

          1265 svd      RET   fcntl 2

          1265 svd      CALL  fcntl(0x5,0x4,0x6)

          1265 svd      RET   fcntl 0

          1265 svd      CALL  fstat(0x1,0xbfbff2b8)

          1265 svd      RET   fstat 0

          1265 svd      CALL  ioctl(0x1,TIOCGETA,0xbfbff2ec)

          1265 svd      RET   ioctl 0

          1265 svd      CALL  write(0x1,0x8071c00,0x12)

          1265 svd      GIO   fd 1 wrote 18 bytes

               "127.0.0.1   36001

               "

          1265 svd      RET   write 18/0x12

          1265 svd      CALL  setsockopt(0x5,0xffff,0x4,0xbfbff4fc,0x4)

          1265 svd      RET   setsockopt 0

          1265 svd      CALL  bind(0x5,0xbfbff51c,0x10)

          1265 svd      RET   bind -1 errno 49 Can't assign requested address

          1265 svd      CALL  setsockopt(0x5,0xffff,0x80,0xbfbff4bc,0x8)

          1265 svd      RET   setsockopt 0

          1265 svd      CALL  shutdown(0x5,0x2)

          1265 svd      RET   shutdown 0

         
        • Maxim F. Ischenko

          I change line

          addr.sin_addr = getaddress(ia);

          into

          addr.sin_addr.s_addr = htonl(INADDR_ANY);

          in TCPSocket::TCPSocket() ctor

          and all magically start working ;-)

          Now I suspect that problem is in InetAddress class

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.