author | dfuchs |
Fri, 22 Nov 2019 11:52:48 +0000 | |
changeset 59224 | 55fdee124e89 |
parent 59200 | a686b67a59d9 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
2 |
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package java.net; |
|
26 |
||
27 |
import java.io.FileDescriptor; |
|
28 |
import java.io.IOException; |
|
48737
7c12219870fd
8195059: Update java.net Socket and DatagramSocket implementations to use Cleaner
rriggs
parents:
47216
diff
changeset
|
29 |
import java.util.Collections; |
7c12219870fd
8195059: Update java.net Socket and DatagramSocket implementations to use Cleaner
rriggs
parents:
47216
diff
changeset
|
30 |
import java.util.HashSet; |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
31 |
import java.util.Objects; |
36115 | 32 |
import java.util.Set; |
48737
7c12219870fd
8195059: Update java.net Socket and DatagramSocket implementations to use Cleaner
rriggs
parents:
47216
diff
changeset
|
33 |
|
7c12219870fd
8195059: Update java.net Socket and DatagramSocket implementations to use Cleaner
rriggs
parents:
47216
diff
changeset
|
34 |
import sun.net.ResourceManager; |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
35 |
import sun.net.ext.ExtendedSocketOptions; |
55375 | 36 |
import sun.net.util.IPAddressUtil; |
37593
824750ada3d6
8154231: Simplify access to System properties from JDK code
redestad
parents:
36115
diff
changeset
|
37 |
import sun.security.action.GetPropertyAction; |
2 | 38 |
|
39 |
/** |
|
40 |
* Abstract datagram and multicast socket implementation base class. |
|
41 |
* Note: This is not a public class, so that applets cannot call |
|
42 |
* into the implementation directly and hence cannot bypass the |
|
43 |
* security checks present in the DatagramSocket and MulticastSocket |
|
44 |
* classes. |
|
45 |
* |
|
46 |
* @author Pavani Diwanji |
|
47 |
*/ |
|
48 |
||
49 |
abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl |
|
50 |
{ |
|
51 |
/* timeout value for receive() */ |
|
52 |
int timeout = 0; |
|
53 |
boolean connected = false; |
|
54 |
private int trafficClass = 0; |
|
10693
6e9ebed2e783
7084030: DatagramSocket.getLocalAddress inconsistent on XP/2003 when IPv6 enabled and socket is connected
chegar
parents:
10596
diff
changeset
|
55 |
protected InetAddress connectedAddress = null; |
2 | 56 |
private int connectedPort = -1; |
59200
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
57 |
private final boolean isMulticast; |
2 | 58 |
|
37781
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
59 |
private static final String os = |
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
60 |
GetPropertyAction.privilegedGetProperty("os.name"); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
61 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
62 |
/** |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
63 |
* flag set if the native connect() call not to be used |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
64 |
*/ |
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
32503
diff
changeset
|
65 |
private static final boolean connectDisabled = os.contains("OS X"); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
66 |
|
2 | 67 |
/** |
68 |
* Load net library into runtime. |
|
69 |
*/ |
|
70 |
static { |
|
55693
9a97b1393e72
8227587: Add internal privileged System.loadLibrary
redestad
parents:
55375
diff
changeset
|
71 |
jdk.internal.loader.BootLoader.loadLibrary("net"); |
2 | 72 |
} |
73 |
||
36115 | 74 |
private static volatile boolean checkedReusePort; |
75 |
private static volatile boolean isReusePortAvailable; |
|
76 |
||
77 |
/** |
|
78 |
* Tells whether SO_REUSEPORT is supported. |
|
79 |
*/ |
|
80 |
static boolean isReusePortAvailable() { |
|
81 |
if (!checkedReusePort) { |
|
82 |
isReusePortAvailable = isReusePortAvailable0(); |
|
83 |
checkedReusePort = true; |
|
84 |
} |
|
85 |
return isReusePortAvailable; |
|
86 |
} |
|
87 |
||
59200
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
88 |
AbstractPlainDatagramSocketImpl(boolean isMulticast) { |
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
89 |
this.isMulticast = isMulticast; |
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
90 |
} |
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
91 |
|
36115 | 92 |
/** |
2 | 93 |
* Creates a datagram socket |
94 |
*/ |
|
95 |
protected synchronized void create() throws SocketException { |
|
10594
d6723ee39ebf
7073491: -Dsun.net.maxDatagramSockets=1 does not work correctly with system.gc()
michaelm
parents:
9035
diff
changeset
|
96 |
ResourceManager.beforeUdpCreate(); |
2 | 97 |
fd = new FileDescriptor(); |
8817
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
98 |
try { |
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
99 |
datagramSocketCreate(); |
48737
7c12219870fd
8195059: Update java.net Socket and DatagramSocket implementations to use Cleaner
rriggs
parents:
47216
diff
changeset
|
100 |
SocketCleanable.register(fd); |
8817
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
101 |
} catch (SocketException ioe) { |
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
102 |
ResourceManager.afterUdpClose(); |
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
103 |
fd = null; |
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
104 |
throw ioe; |
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
105 |
} |
2 | 106 |
} |
107 |
||
108 |
/** |
|
109 |
* Binds a datagram socket to a local port. |
|
110 |
*/ |
|
111 |
protected synchronized void bind(int lport, InetAddress laddr) |
|
112 |
throws SocketException { |
|
55375 | 113 |
if (laddr.isLinkLocalAddress()) { |
114 |
laddr = IPAddressUtil.toScopedAddress(laddr); |
|
115 |
} |
|
2 | 116 |
bind0(lport, laddr); |
117 |
} |
|
118 |
||
119 |
protected abstract void bind0(int lport, InetAddress laddr) |
|
120 |
throws SocketException; |
|
121 |
||
122 |
/** |
|
123 |
* Sends a datagram packet. The packet contains the data and the |
|
124 |
* destination address to send the packet to. |
|
14014 | 125 |
* @param p the packet to be sent. |
2 | 126 |
*/ |
55375 | 127 |
protected void send(DatagramPacket p) throws IOException { |
128 |
InetAddress orig = p.getAddress(); |
|
129 |
if (orig.isLinkLocalAddress()) { |
|
130 |
InetAddress scoped = IPAddressUtil.toScopedAddress(orig); |
|
131 |
if (orig != scoped) { |
|
132 |
p = new DatagramPacket(p.getData(), p.getOffset(), |
|
133 |
p.getLength(), scoped, p.getPort()); |
|
134 |
} |
|
135 |
} |
|
136 |
send0(p); |
|
137 |
} |
|
138 |
||
139 |
protected abstract void send0(DatagramPacket p) throws IOException; |
|
2 | 140 |
|
141 |
/** |
|
142 |
* Connects a datagram socket to a remote destination. This associates the remote |
|
143 |
* address with the local socket so that datagrams may only be sent to this destination |
|
144 |
* and received from this destination. |
|
145 |
* @param address the remote InetAddress to connect to |
|
146 |
* @param port the remote port number |
|
147 |
*/ |
|
148 |
protected void connect(InetAddress address, int port) throws SocketException { |
|
55375 | 149 |
if (address.isLinkLocalAddress()) { |
150 |
address = IPAddressUtil.toScopedAddress(address); |
|
151 |
} |
|
2 | 152 |
connect0(address, port); |
153 |
connectedAddress = address; |
|
154 |
connectedPort = port; |
|
155 |
connected = true; |
|
156 |
} |
|
157 |
||
158 |
/** |
|
159 |
* Disconnects a previously connected socket. Does nothing if the socket was |
|
160 |
* not connected already. |
|
161 |
*/ |
|
162 |
protected void disconnect() { |
|
16870 | 163 |
disconnect0(connectedAddress.holder().getFamily()); |
2 | 164 |
connected = false; |
165 |
connectedAddress = null; |
|
166 |
connectedPort = -1; |
|
167 |
} |
|
168 |
||
169 |
/** |
|
170 |
* Peek at the packet to see who it is from. |
|
14014 | 171 |
* @param i the address to populate with the sender address |
2 | 172 |
*/ |
173 |
protected abstract int peek(InetAddress i) throws IOException; |
|
174 |
protected abstract int peekData(DatagramPacket p) throws IOException; |
|
175 |
/** |
|
176 |
* Receive the datagram packet. |
|
14014 | 177 |
* @param p the packet to receive into |
2 | 178 |
*/ |
179 |
protected synchronized void receive(DatagramPacket p) |
|
180 |
throws IOException { |
|
181 |
receive0(p); |
|
182 |
} |
|
183 |
||
184 |
protected abstract void receive0(DatagramPacket p) |
|
185 |
throws IOException; |
|
186 |
||
187 |
/** |
|
188 |
* Set the TTL (time-to-live) option. |
|
14014 | 189 |
* @param ttl TTL to be set. |
2 | 190 |
*/ |
191 |
protected abstract void setTimeToLive(int ttl) throws IOException; |
|
192 |
||
193 |
/** |
|
194 |
* Get the TTL (time-to-live) option. |
|
195 |
*/ |
|
196 |
protected abstract int getTimeToLive() throws IOException; |
|
197 |
||
198 |
/** |
|
199 |
* Set the TTL (time-to-live) option. |
|
14014 | 200 |
* @param ttl TTL to be set. |
2 | 201 |
*/ |
10596
39b3a979e600
7090158: Networking Libraries don't build with javac -Werror
chegar
parents:
10594
diff
changeset
|
202 |
@Deprecated |
2 | 203 |
protected abstract void setTTL(byte ttl) throws IOException; |
204 |
||
205 |
/** |
|
206 |
* Get the TTL (time-to-live) option. |
|
207 |
*/ |
|
10596
39b3a979e600
7090158: Networking Libraries don't build with javac -Werror
chegar
parents:
10594
diff
changeset
|
208 |
@Deprecated |
2 | 209 |
protected abstract byte getTTL() throws IOException; |
210 |
||
211 |
/** |
|
212 |
* Join the multicast group. |
|
14014 | 213 |
* @param inetaddr multicast address to join. |
2 | 214 |
*/ |
215 |
protected void join(InetAddress inetaddr) throws IOException { |
|
216 |
join(inetaddr, null); |
|
217 |
} |
|
218 |
||
219 |
/** |
|
220 |
* Leave the multicast group. |
|
14014 | 221 |
* @param inetaddr multicast address to leave. |
2 | 222 |
*/ |
223 |
protected void leave(InetAddress inetaddr) throws IOException { |
|
224 |
leave(inetaddr, null); |
|
225 |
} |
|
226 |
/** |
|
227 |
* Join the multicast group. |
|
14014 | 228 |
* @param mcastaddr multicast address to join. |
2 | 229 |
* @param netIf specifies the local interface to receive multicast |
230 |
* datagram packets |
|
231 |
* @throws IllegalArgumentException if mcastaddr is null or is a |
|
232 |
* SocketAddress subclass not supported by this socket |
|
233 |
* @since 1.4 |
|
234 |
*/ |
|
235 |
||
236 |
protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) |
|
237 |
throws IOException { |
|
238 |
if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress)) |
|
239 |
throw new IllegalArgumentException("Unsupported address type"); |
|
240 |
join(((InetSocketAddress)mcastaddr).getAddress(), netIf); |
|
241 |
} |
|
242 |
||
243 |
protected abstract void join(InetAddress inetaddr, NetworkInterface netIf) |
|
244 |
throws IOException; |
|
245 |
||
246 |
/** |
|
247 |
* Leave the multicast group. |
|
14014 | 248 |
* @param mcastaddr multicast address to leave. |
2 | 249 |
* @param netIf specified the local interface to leave the group at |
250 |
* @throws IllegalArgumentException if mcastaddr is null or is a |
|
251 |
* SocketAddress subclass not supported by this socket |
|
252 |
* @since 1.4 |
|
253 |
*/ |
|
254 |
protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) |
|
255 |
throws IOException { |
|
256 |
if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress)) |
|
257 |
throw new IllegalArgumentException("Unsupported address type"); |
|
258 |
leave(((InetSocketAddress)mcastaddr).getAddress(), netIf); |
|
259 |
} |
|
260 |
||
261 |
protected abstract void leave(InetAddress inetaddr, NetworkInterface netIf) |
|
262 |
throws IOException; |
|
263 |
||
264 |
/** |
|
265 |
* Close the socket. |
|
266 |
*/ |
|
267 |
protected void close() { |
|
268 |
if (fd != null) { |
|
48737
7c12219870fd
8195059: Update java.net Socket and DatagramSocket implementations to use Cleaner
rriggs
parents:
47216
diff
changeset
|
269 |
SocketCleanable.unregister(fd); |
2 | 270 |
datagramSocketClose(); |
8817
5351579c46a9
6981922: DNS cache poisoning by untrusted applets
michaelm
parents:
5506
diff
changeset
|
271 |
ResourceManager.afterUdpClose(); |
2 | 272 |
fd = null; |
273 |
} |
|
274 |
} |
|
275 |
||
276 |
protected boolean isClosed() { |
|
277 |
return (fd == null) ? true : false; |
|
278 |
} |
|
279 |
||
280 |
/** |
|
281 |
* set a value - since we only support (setting) binary options |
|
282 |
* here, o must be a Boolean |
|
283 |
*/ |
|
284 |
||
285 |
public void setOption(int optID, Object o) throws SocketException { |
|
286 |
if (isClosed()) { |
|
287 |
throw new SocketException("Socket Closed"); |
|
288 |
} |
|
289 |
switch (optID) { |
|
290 |
/* check type safety b4 going native. These should never |
|
291 |
* fail, since only java.Socket* has access to |
|
292 |
* PlainSocketImpl.setOption(). |
|
293 |
*/ |
|
294 |
case SO_TIMEOUT: |
|
295 |
if (o == null || !(o instanceof Integer)) { |
|
296 |
throw new SocketException("bad argument for SO_TIMEOUT"); |
|
297 |
} |
|
298 |
int tmp = ((Integer) o).intValue(); |
|
299 |
if (tmp < 0) |
|
300 |
throw new IllegalArgumentException("timeout < 0"); |
|
301 |
timeout = tmp; |
|
302 |
return; |
|
303 |
case IP_TOS: |
|
304 |
if (o == null || !(o instanceof Integer)) { |
|
305 |
throw new SocketException("bad argument for IP_TOS"); |
|
306 |
} |
|
307 |
trafficClass = ((Integer)o).intValue(); |
|
308 |
break; |
|
309 |
case SO_REUSEADDR: |
|
310 |
if (o == null || !(o instanceof Boolean)) { |
|
311 |
throw new SocketException("bad argument for SO_REUSEADDR"); |
|
312 |
} |
|
313 |
break; |
|
314 |
case SO_BROADCAST: |
|
315 |
if (o == null || !(o instanceof Boolean)) { |
|
316 |
throw new SocketException("bad argument for SO_BROADCAST"); |
|
317 |
} |
|
318 |
break; |
|
319 |
case SO_BINDADDR: |
|
320 |
throw new SocketException("Cannot re-bind Socket"); |
|
321 |
case SO_RCVBUF: |
|
322 |
case SO_SNDBUF: |
|
323 |
if (o == null || !(o instanceof Integer) || |
|
324 |
((Integer)o).intValue() < 0) { |
|
325 |
throw new SocketException("bad argument for SO_SNDBUF or " + |
|
326 |
"SO_RCVBUF"); |
|
327 |
} |
|
328 |
break; |
|
329 |
case IP_MULTICAST_IF: |
|
330 |
if (o == null || !(o instanceof InetAddress)) |
|
331 |
throw new SocketException("bad argument for IP_MULTICAST_IF"); |
|
332 |
break; |
|
333 |
case IP_MULTICAST_IF2: |
|
334 |
if (o == null || !(o instanceof NetworkInterface)) |
|
335 |
throw new SocketException("bad argument for IP_MULTICAST_IF2"); |
|
336 |
break; |
|
337 |
case IP_MULTICAST_LOOP: |
|
338 |
if (o == null || !(o instanceof Boolean)) |
|
339 |
throw new SocketException("bad argument for IP_MULTICAST_LOOP"); |
|
340 |
break; |
|
36115 | 341 |
case SO_REUSEPORT: |
342 |
if (o == null || !(o instanceof Boolean)) { |
|
343 |
throw new SocketException("bad argument for SO_REUSEPORT"); |
|
344 |
} |
|
345 |
if (!supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) { |
|
346 |
throw new UnsupportedOperationException("unsupported option"); |
|
347 |
} |
|
348 |
break; |
|
2 | 349 |
default: |
350 |
throw new SocketException("invalid option: " + optID); |
|
351 |
} |
|
352 |
socketSetOption(optID, o); |
|
353 |
} |
|
354 |
||
355 |
/* |
|
356 |
* get option's state - set or not |
|
357 |
*/ |
|
358 |
||
359 |
public Object getOption(int optID) throws SocketException { |
|
360 |
if (isClosed()) { |
|
361 |
throw new SocketException("Socket Closed"); |
|
362 |
} |
|
363 |
||
364 |
Object result; |
|
365 |
||
366 |
switch (optID) { |
|
367 |
case SO_TIMEOUT: |
|
25522
10d789df41bb
8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes
prr
parents:
23010
diff
changeset
|
368 |
result = timeout; |
2 | 369 |
break; |
370 |
||
371 |
case IP_TOS: |
|
372 |
result = socketGetOption(optID); |
|
373 |
if ( ((Integer)result).intValue() == -1) { |
|
25522
10d789df41bb
8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes
prr
parents:
23010
diff
changeset
|
374 |
result = trafficClass; |
2 | 375 |
} |
376 |
break; |
|
377 |
||
378 |
case SO_BINDADDR: |
|
379 |
case IP_MULTICAST_IF: |
|
380 |
case IP_MULTICAST_IF2: |
|
381 |
case SO_RCVBUF: |
|
382 |
case SO_SNDBUF: |
|
383 |
case IP_MULTICAST_LOOP: |
|
384 |
case SO_REUSEADDR: |
|
385 |
case SO_BROADCAST: |
|
386 |
result = socketGetOption(optID); |
|
387 |
break; |
|
388 |
||
36115 | 389 |
case SO_REUSEPORT: |
390 |
if (!supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) { |
|
391 |
throw new UnsupportedOperationException("unsupported option"); |
|
392 |
} |
|
393 |
result = socketGetOption(optID); |
|
394 |
break; |
|
395 |
||
2 | 396 |
default: |
397 |
throw new SocketException("invalid option: " + optID); |
|
398 |
} |
|
399 |
||
400 |
return result; |
|
401 |
} |
|
402 |
||
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
403 |
static final ExtendedSocketOptions extendedOptions = |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
404 |
ExtendedSocketOptions.getInstance(); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
405 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
406 |
private static final Set<SocketOption<?>> datagramSocketOptions = datagramSocketOptions(); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
407 |
private static final Set<SocketOption<?>> multicastSocketOptions = multicastSocketOptions(); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
408 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
409 |
private static Set<SocketOption<?>> datagramSocketOptions() { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
410 |
HashSet<SocketOption<?>> options = new HashSet<>(); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
411 |
options.add(StandardSocketOptions.SO_SNDBUF); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
412 |
options.add(StandardSocketOptions.SO_RCVBUF); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
413 |
options.add(StandardSocketOptions.SO_REUSEADDR); |
59200
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
414 |
options.add(StandardSocketOptions.SO_BROADCAST); |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
415 |
options.add(StandardSocketOptions.IP_TOS); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
416 |
if (isReusePortAvailable()) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
417 |
options.add(StandardSocketOptions.SO_REUSEPORT); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
418 |
options.addAll(ExtendedSocketOptions.datagramSocketOptions()); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
419 |
return Collections.unmodifiableSet(options); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
420 |
} |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
421 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
422 |
private static Set<SocketOption<?>> multicastSocketOptions() { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
423 |
HashSet<SocketOption<?>> options = new HashSet<>(); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
424 |
options.add(StandardSocketOptions.SO_SNDBUF); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
425 |
options.add(StandardSocketOptions.SO_RCVBUF); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
426 |
options.add(StandardSocketOptions.SO_REUSEADDR); |
59200
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
427 |
options.add(StandardSocketOptions.SO_BROADCAST); |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
428 |
options.add(StandardSocketOptions.IP_TOS); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
429 |
options.add(StandardSocketOptions.IP_MULTICAST_IF); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
430 |
options.add(StandardSocketOptions.IP_MULTICAST_TTL); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
431 |
options.add(StandardSocketOptions.IP_MULTICAST_LOOP); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
432 |
if (isReusePortAvailable()) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
433 |
options.add(StandardSocketOptions.SO_REUSEPORT); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
434 |
options.addAll(ExtendedSocketOptions.datagramSocketOptions()); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
435 |
return Collections.unmodifiableSet(options); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
436 |
} |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
437 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
438 |
@Override |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
439 |
protected Set<SocketOption<?>> supportedOptions() { |
59200
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
440 |
if (isMulticast) |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
441 |
return multicastSocketOptions; |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
442 |
else |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
443 |
return datagramSocketOptions; |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
444 |
} |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
445 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
446 |
@Override |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
447 |
protected <T> void setOption(SocketOption<T> name, T value) throws IOException { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
448 |
Objects.requireNonNull(name); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
449 |
if (!supportedOptions().contains(name)) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
450 |
throw new UnsupportedOperationException("'" + name + "' not supported"); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
451 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
452 |
if (!name.type().isInstance(value)) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
453 |
throw new IllegalArgumentException("Invalid value '" + value + "'"); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
454 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
455 |
if (isClosed()) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
456 |
throw new SocketException("Socket closed"); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
457 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
458 |
if (name == StandardSocketOptions.SO_SNDBUF) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
459 |
if (((Integer)value).intValue() < 0) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
460 |
throw new IllegalArgumentException("Invalid send buffer size:" + value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
461 |
setOption(SocketOptions.SO_SNDBUF, value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
462 |
} else if (name == StandardSocketOptions.SO_RCVBUF) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
463 |
if (((Integer)value).intValue() < 0) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
464 |
throw new IllegalArgumentException("Invalid recv buffer size:" + value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
465 |
setOption(SocketOptions.SO_RCVBUF, value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
466 |
} else if (name == StandardSocketOptions.SO_REUSEADDR) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
467 |
setOption(SocketOptions.SO_REUSEADDR, value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
468 |
} else if (name == StandardSocketOptions.SO_REUSEPORT) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
469 |
setOption(SocketOptions.SO_REUSEPORT, value); |
59200
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
470 |
} else if (name == StandardSocketOptions.SO_BROADCAST) { |
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
471 |
setOption(SocketOptions.SO_BROADCAST, value); |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
472 |
} else if (name == StandardSocketOptions.IP_TOS) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
473 |
int i = ((Integer)value).intValue(); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
474 |
if (i < 0 || i > 255) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
475 |
throw new IllegalArgumentException("Invalid IP_TOS value: " + value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
476 |
setOption(SocketOptions.IP_TOS, value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
477 |
} else if (name == StandardSocketOptions.IP_MULTICAST_IF ) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
478 |
setOption(SocketOptions.IP_MULTICAST_IF2, value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
479 |
} else if (name == StandardSocketOptions.IP_MULTICAST_TTL) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
480 |
int i = ((Integer)value).intValue(); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
481 |
if (i < 0 || i > 255) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
482 |
throw new IllegalArgumentException("Invalid TTL/hop value: " + value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
483 |
setTimeToLive((Integer)value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
484 |
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP) { |
59224
55fdee124e89
8233296: MulticastSocket getOption/setOption inverts the value of IP_MULTICAST_LOOP
dfuchs
parents:
59200
diff
changeset
|
485 |
boolean enable = (boolean) value; |
55fdee124e89
8233296: MulticastSocket getOption/setOption inverts the value of IP_MULTICAST_LOOP
dfuchs
parents:
59200
diff
changeset
|
486 |
// Legacy setOption expects true to mean 'disabled' |
55fdee124e89
8233296: MulticastSocket getOption/setOption inverts the value of IP_MULTICAST_LOOP
dfuchs
parents:
59200
diff
changeset
|
487 |
setOption(SocketOptions.IP_MULTICAST_LOOP, !enable); |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
488 |
} else if (extendedOptions.isOptionSupported(name)) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
489 |
extendedOptions.setOption(fd, name, value); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
490 |
} else { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
491 |
throw new AssertionError("unknown option :" + name); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
492 |
} |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
493 |
} |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
494 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
495 |
@Override |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
496 |
@SuppressWarnings("unchecked") |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
497 |
protected <T> T getOption(SocketOption<T> name) throws IOException { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
498 |
Objects.requireNonNull(name); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
499 |
if (!supportedOptions().contains(name)) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
500 |
throw new UnsupportedOperationException("'" + name + "' not supported"); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
501 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
502 |
if (isClosed()) |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
503 |
throw new SocketException("Socket closed"); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
504 |
|
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
505 |
if (name == StandardSocketOptions.SO_SNDBUF) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
506 |
return (T) getOption(SocketOptions.SO_SNDBUF); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
507 |
} else if (name == StandardSocketOptions.SO_RCVBUF) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
508 |
return (T) getOption(SocketOptions.SO_RCVBUF); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
509 |
} else if (name == StandardSocketOptions.SO_REUSEADDR) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
510 |
return (T) getOption(SocketOptions.SO_REUSEADDR); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
511 |
} else if (name == StandardSocketOptions.SO_REUSEPORT) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
512 |
return (T) getOption(SocketOptions.SO_REUSEPORT); |
59200
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
513 |
} else if (name == StandardSocketOptions.SO_BROADCAST) { |
a686b67a59d9
8234103: DatagramSocketImpl::socket is not needed
pconcannon
parents:
55693
diff
changeset
|
514 |
return (T) getOption(SocketOptions.SO_BROADCAST); |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
515 |
} else if (name == StandardSocketOptions.IP_TOS) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
516 |
return (T) getOption(SocketOptions.IP_TOS); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
517 |
} else if (name == StandardSocketOptions.IP_MULTICAST_IF) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
518 |
return (T) getOption(SocketOptions.IP_MULTICAST_IF2); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
519 |
} else if (name == StandardSocketOptions.IP_MULTICAST_TTL) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
520 |
return (T) ((Integer) getTimeToLive()); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
521 |
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP) { |
59224
55fdee124e89
8233296: MulticastSocket getOption/setOption inverts the value of IP_MULTICAST_LOOP
dfuchs
parents:
59200
diff
changeset
|
522 |
boolean disabled = (boolean) getOption(SocketOptions.IP_MULTICAST_LOOP); |
55fdee124e89
8233296: MulticastSocket getOption/setOption inverts the value of IP_MULTICAST_LOOP
dfuchs
parents:
59200
diff
changeset
|
523 |
// Legacy getOption returns true when disabled |
55fdee124e89
8233296: MulticastSocket getOption/setOption inverts the value of IP_MULTICAST_LOOP
dfuchs
parents:
59200
diff
changeset
|
524 |
return (T) Boolean.valueOf(!disabled); |
55081
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
525 |
} else if (extendedOptions.isOptionSupported(name)) { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
526 |
return (T) extendedOptions.getOption(fd, name); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
527 |
} else { |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
528 |
throw new AssertionError("unknown option: " + name); |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
529 |
} |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
530 |
} |
dd321e3596c0
8224477: java.net socket types new-style socket option methods - spec and impl mismatch
chegar
parents:
48737
diff
changeset
|
531 |
|
2 | 532 |
protected abstract void datagramSocketCreate() throws SocketException; |
533 |
protected abstract void datagramSocketClose(); |
|
534 |
protected abstract void socketSetOption(int opt, Object val) |
|
535 |
throws SocketException; |
|
536 |
protected abstract Object socketGetOption(int opt) throws SocketException; |
|
537 |
||
538 |
protected abstract void connect0(InetAddress address, int port) throws SocketException; |
|
539 |
protected abstract void disconnect0(int family); |
|
540 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
541 |
protected boolean nativeConnectDisabled() { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
542 |
return connectDisabled; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
10693
diff
changeset
|
543 |
} |
27078 | 544 |
|
32503
1478c9130534
8072466: Deadlock when initializing MulticastSocket and DatagramSocket
igerasim
parents:
29986
diff
changeset
|
545 |
abstract int dataAvailable(); |
36115 | 546 |
private static native boolean isReusePortAvailable0(); |
2 | 547 |
} |