United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 4546610 (so) ServerSocketChannel bind does not detect address in use (w2k, reg)
4546610 : (so) ServerSocketChannel bind does not detect address in use (w2k, reg)

Details
Type:
Bug
Submit Date:
2001-12-04
Status:
Closed
Updated Date:
2002-06-12
Project Name:
JDK
Resolved Date:
2002-02-08
Component:
core-libs
OS:
windows_2000
Sub-Component:
java.nio
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.1

Related Reports

Sub Tasks

Description

Name: nt126004			Date: 12/04/2001


java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

On win2k multiple ServerSocketChannel object can bind to the same address
without raising a java.net.SocketException, Address already in use.  The
following code demonstrates the problem.  Running this on a win2k machine
encounters no exception on the second bind call.  The same thing on linux-2.4.2
throws an appropriate exception.

import java.net.InetSocketAddress;
import java.nio.channels.ServerSocketChannel;

public class ServerSocketChannelBroken {
    public static void main(String[] args) throws Exception {

	ServerSocketChannel ssc0 = ServerSocketChannel.open();
	ssc0.socket().bind(new InetSocketAddress("127.0.0.1", 1234));

	ServerSocketChannel ssc1 = ServerSocketChannel.open();
        // This fails correctly on linux-2.4.2 & Solaris but
        // surprisingly succeeds on win2k
	ssc1.socket().bind(new InetSocketAddress("127.0.0.1", 1234));
    }
}

I'm submitting this as a "can't make progress" severity.  Of course I could
make progress by not using java.nio.*, but my intention is to use it on
win2k platforms.  It really is unusable with this because there is no
satisfactory workaround.  If you use a conventional ServerSocket and thread to
accept connections, you are then forced to use a conventional java.net.Socket
rather than a java.nio.channels.SocketChannel, since it is impossible to
instantiate an instance of the latter with an existing socket.  Thus the whole
package is unusable for win32.

REGRESSION:
last worked in version 1.4 beta 2
(Review ID: 136264) 
======================================================================

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
generic
hopper

FIXED IN:
hopper

INTEGRATED IN:
hopper

VERIFIED IN:
hopper


                                     
2004-06-14
WORK AROUND



Name: nt126004			Date: 12/04/2001


Customer Workaround :
Don't use java.nio.channels on win2k platform
======================================================================


Invoke setReuseAddress(false) on the server socket before before invoking
the bind method.
###@###.### 2002-01-22
                                     
2002-01-22
EVALUATION

The issue is being examined.
###@###.### 2002-01-22

Due to some quirks on various platforms we are taking the same strategy as java.net for SO_REUSEADDR.
###@###.### 2002-01-25
                                     
2002-01-22



Hardware and Software, Engineered to Work Together