Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bind several times to the same port in Mac OS X




My PowerBook lets me bind to the same port twice using NIO. The following code throws an IOException under Windows and Linux, but not under Mac OS X:


bindTwice( port) IOException
InetSocketAddress listenAddress =
InetSocketAddress(port);
 
ServerSocketChannel firstChannel = ServerSocketChannel.open();
ServerSocket firstSocket = firstChannel.socket();
firstSocket.bind(listenAddress);
 
ServerSocketChannel secondChannel = ServerSocketChannel.open();
ServerSocket secondSocket = secondChannel.socket();
secondSocket.bind(listenAddress);


It wouldn't be too big a deal but I want my application to fail if it can't bind! One horrible problem that has come up in my tests is this:
1. Bind to port X as server.
2. Connect to self on port X as client.
Now the client has fully connected but server has not received anything! Another server process that has binded to the same port is receiving the data instead.

Is this a bug in the Mac JVM?

Any information on this problem will be appreciated, thanks!

Cheers,
Jesse Wilson
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.