Professional Web Applications Themes

java.net.BindException on Mac OS 10.3.4 - Mac Programming

I have a strange problem which I only noticed today. I can't open a server socket at all using Java. I always get a BindException, even when I know for a fact that the port is not in use. This only affects Java apps; Apache is working fine, so's CVS, and I can listen on any port I want with netcat. This seems to affect all Java programs, not just the ones I wrote. Those same programs were working fine just a few days ago (I have both JBoss and Jetty installed, but most of the time they're not running.) ...

  1. #1

    Default java.net.BindException on Mac OS 10.3.4

    I have a strange problem which I only noticed today. I can't open a
    server socket at all using Java. I always get a BindException, even when
    I know for a fact that the port is not in use. This only affects Java
    apps; Apache is working fine, so's CVS, and I can listen on any port I
    want with netcat.

    This seems to affect all Java programs, not just the ones I wrote. Those
    same programs were working fine just a few days ago (I have both JBoss
    and Jetty installed, but most of the time they're not running.)

    Could this have anything to do with the latest OS update?

    -MB
    Mike Guest

  2. #2

    Default Re: java.net.BindException on Mac OS 10.3.4

    In article
    <nyroc.rr.com>,
    Mike Baranczak <sourceforge.net> wrote:
     


    So I rebooted and that seems to have fixed it. I'd still like to know
    what happened, though. Any ideas?

    -MB
    Mike Guest

  3. #3

    Default Re: java.net.BindException on Mac OS 10.3.4

    On Tue, 01 Jun 2004 01:10:35 +0000, Mike Baranczak wrote:
     
    Works here (10.3.4 also). Did the upgrade enable the (built in) firewall?

    Simon.
    Simon Guest

  4. #4

    Default Re: java.net.BindException on Mac OS 10.3.4

    Mike Baranczak wrote:
     

    If a program is messily terminated, I believe Mac OS X will prevent any
    app from listening on the same port for a while, to avoid receiving
    stale data.
    Peter Guest

  5. #5

    Default Re: java.net.BindException on Mac OS 10.3.4

    In article <c9ids6$e77$apple.com>,
    Peter Ammon <com> wrote:
     
    >
    > If a program is messily terminated, I believe Mac OS X will prevent any
    > app from listening on the same port for a while, to avoid receiving
    > stale data.[/ref]


    Except that this affected ALL the ports I tried. And like I said, it
    only affected Java - those same ports worked with netcat.

    This problem went away after rebooting, and I haven't been able to
    duplicate it. I'll just put this one down as bad network mojo.

    -MB
    Mike Guest

  6. #6

    Default Re: java.net.BindException on Mac OS 10.3.4

    On Tue, 01 Jun 2004 00:10:35 GMT, Mike Baranczak wrote: 

    The error indicates either that there is already a ServerSocket using
    the given port, or that you do not have sufficient privileges to bind
    the port (typically the case for ports 1-1023). The exception message
    should indicate which of the situations has occurred.

    On some platforms, the existence of a (connected) Socket will prevent
    the ServerSocket from binding the same port. This could be the case if
    you have accepted a connection and attempt to restart the server while
    an earlier forked client is still connected.

    Even though you "know" that the port is not in use, I would suggest
    that you use "netstat -a" to confirm that, or lsof to see which
    processes hold open socket descriptors to the port in question,
    something like this:

    lsof -i tcp:32567

    Although I believe that ServerSockets use SO_REUSEADDR by default, you
    might try using setReuseAddress() yourself before attempting to bind
    your ServerSocket:

    ServerSocket ss = new ServerSocket(); // create unbound SS
    ss.setReuseAddress(true);
    ss.bind(new InetSocketAddress(port));

    What happens when you attempt to bind port 0?

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s b a l d e r 1 3 . s e
    Gordon Guest

Similar Threads

  1. Replies: 2
    Last Post: February 5th, 03:33 PM
  2. #25651 [Bgs]: mixing --with-java and --enable-debug pull out java
    By fperez at tuzsa dot es in forum PHP Development
    Replies: 0
    Last Post: September 26th, 06:26 AM
  3. #25651 [NEW]: mixing --with-java and --enable-debug pull out java
    By fperez at tuzsa dot es in forum PHP Development
    Replies: 0
    Last Post: September 25th, 07:04 AM
  4. Replies: 0
    Last Post: August 8th, 11:18 AM
  5. Replies: 0
    Last Post: August 2nd, 08:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139