Name: diC59631 Date: 06/11/98
1. Open a server socket on a port
2. Open another one on the same port
-- Correct behaviour. Does not work.
3. Connect to the server socket
4. Close the server socket
5. Open another one on the same port
-- Fails with address in use exception
-- Wrong behaviour
6. Close the socket opened at step 3
7. Repease step 5
-- Succeeds.
Step 5 succeeds under Solaris. JDK1.02 under
windows NT exhibits the correct behaviour.
Source to test the above case:
import java.net.ServerSocket;
import java.net.Socket;
public class t {
public static void main(String args[]) throws Exception {
ServerSocket s1, s2;
Socket s, ss;
s1 = new ServerSocket(1099);
try {
s2 = new ServerSocket(1099);
System.out.println("SUCCESS");
System.in.read();
return;
} catch (Exception e) {
System.out.println("Could not open two listeners at the same port");
e.printStackTrace();
}
// Connect to host 1099
s = new Socket("localhost", 1099);
ss = s1.accept();
s1.close();
System.in.read();
try {
s2 = new ServerSocket(1099);
return;
} catch (Exception e) {
System.out.println("Could not open two listeners at the same port");
System.out.println(" even after closing the first listener");
e.printStackTrace();
}
// Nothing at the port
s.close();
ss.close();
try {
s2 = new ServerSocket(1099);
return;
} catch (Exception e) {
System.out.println("This is a serious problem with the OS");
e.printStackTrace();
}
}
}
(Review ID: 24672)
======================================================================
- duplicates
-
JDK-4278322 Socket creation on solaris always set SO_REUSEADDR option
-
- Resolved
-