equal
deleted
inserted
replaced
54 |
54 |
55 class ServerSocketAdaptor // package-private |
55 class ServerSocketAdaptor // package-private |
56 extends ServerSocket |
56 extends ServerSocket |
57 { |
57 { |
58 // The channel being adapted |
58 // The channel being adapted |
59 private final ServerSocketChannelImpl ssc; |
59 private final InetServerSocketChannelImpl ssc; |
60 |
60 |
61 // Timeout "option" value for accepts |
61 // Timeout "option" value for accepts |
62 private volatile int timeout; |
62 private volatile int timeout; |
63 |
63 |
64 static ServerSocket create(ServerSocketChannelImpl ssc) { |
64 static ServerSocket create(InetServerSocketChannelImpl ssc) { |
65 PrivilegedExceptionAction<ServerSocket> pa = () -> new ServerSocketAdaptor(ssc); |
65 PrivilegedExceptionAction<ServerSocket> pa = () -> new ServerSocketAdaptor(ssc); |
66 try { |
66 try { |
67 return AccessController.doPrivileged(pa); |
67 return AccessController.doPrivileged(pa); |
68 } catch (PrivilegedActionException pae) { |
68 } catch (PrivilegedActionException pae) { |
69 throw new InternalError("Should not reach here", pae); |
69 throw new InternalError("Should not reach here", pae); |
70 } |
70 } |
71 } |
71 } |
72 |
72 |
73 private ServerSocketAdaptor(ServerSocketChannelImpl ssc) { |
73 private ServerSocketAdaptor(InetServerSocketChannelImpl ssc) { |
74 super(DummySocketImpl.create()); |
74 super(DummySocketImpl.create()); |
75 this.ssc = ssc; |
75 this.ssc = ssc; |
76 } |
76 } |
77 |
77 |
78 @Override |
78 @Override |
91 } |
91 } |
92 } |
92 } |
93 |
93 |
94 @Override |
94 @Override |
95 public InetAddress getInetAddress() { |
95 public InetAddress getInetAddress() { |
96 InetSocketAddress local = ssc.localAddress(); |
96 InetSocketAddress local = (InetSocketAddress)ssc.localAddress(); |
97 if (local == null) { |
97 if (local == null) { |
98 return null; |
98 return null; |
99 } else { |
99 } else { |
100 return Net.getRevealedLocalAddress(local).getAddress(); |
100 return Net.getRevealedLocalAddress(local).getAddress(); |
101 } |
101 } |
102 } |
102 } |
103 |
103 |
104 @Override |
104 @Override |
105 public int getLocalPort() { |
105 public int getLocalPort() { |
106 InetSocketAddress local = ssc.localAddress(); |
106 InetSocketAddress local = (InetSocketAddress)ssc.localAddress(); |
107 if (local == null) { |
107 if (local == null) { |
108 return -1; |
108 return -1; |
109 } else { |
109 } else { |
110 return local.getPort(); |
110 return local.getPort(); |
111 } |
111 } |