equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package sun.rmi.transport.tcp; |
25 package sun.rmi.transport.tcp; |
26 |
26 |
27 import java.io.IOException; |
27 import java.io.IOException; |
28 import java.net.InetSocketAddress; |
|
29 import java.net.Socket; |
28 import java.net.Socket; |
30 import java.net.ServerSocket; |
29 import java.net.ServerSocket; |
31 import java.rmi.server.RMISocketFactory; |
30 import java.rmi.server.RMISocketFactory; |
32 |
31 |
33 /** |
32 /** |
41 return new Socket(host, port); |
40 return new Socket(host, port); |
42 } |
41 } |
43 |
42 |
44 public ServerSocket createServerSocket(int port) throws IOException |
43 public ServerSocket createServerSocket(int port) throws IOException |
45 { |
44 { |
46 ServerSocket ss = new ServerSocket(); |
45 return new ServerSocket(port); |
47 if (port == 0) { |
|
48 // Only need SO_REUSEADDR if we're using a fixed port. If we |
|
49 // start seeing EADDRINUSE due to collisions in free ports |
|
50 // then we should retry the bind() a few times. |
|
51 ss.setReuseAddress(false); |
|
52 } |
|
53 ss.bind(new InetSocketAddress(port)); |
|
54 return ss; |
|
55 } |
46 } |
56 } |
47 } |