equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1995, 2019, 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 |
27 |
27 |
28 import java.io.IOException; |
28 import java.io.IOException; |
29 import java.nio.channels.DatagramChannel; |
29 import java.nio.channels.DatagramChannel; |
30 import java.security.AccessController; |
30 import java.security.AccessController; |
31 import java.security.PrivilegedExceptionAction; |
31 import java.security.PrivilegedExceptionAction; |
|
32 import java.util.Objects; |
32 import java.util.Set; |
33 import java.util.Set; |
33 import java.util.Collections; |
34 import java.util.Collections; |
34 |
35 |
35 /** |
36 /** |
36 * This class represents a socket for sending and receiving datagram packets. |
37 * This class represents a socket for sending and receiving datagram packets. |
1341 * @since 9 |
1342 * @since 9 |
1342 */ |
1343 */ |
1343 public <T> DatagramSocket setOption(SocketOption<T> name, T value) |
1344 public <T> DatagramSocket setOption(SocketOption<T> name, T value) |
1344 throws IOException |
1345 throws IOException |
1345 { |
1346 { |
|
1347 Objects.requireNonNull(name); |
|
1348 if (isClosed()) |
|
1349 throw new SocketException("Socket is closed"); |
1346 getImpl().setOption(name, value); |
1350 getImpl().setOption(name, value); |
1347 return this; |
1351 return this; |
1348 } |
1352 } |
1349 |
1353 |
1350 /** |
1354 /** |
1369 * do not require any security permission. |
1373 * do not require any security permission. |
1370 * |
1374 * |
1371 * @since 9 |
1375 * @since 9 |
1372 */ |
1376 */ |
1373 public <T> T getOption(SocketOption<T> name) throws IOException { |
1377 public <T> T getOption(SocketOption<T> name) throws IOException { |
|
1378 Objects.requireNonNull(name); |
|
1379 if (isClosed()) |
|
1380 throw new SocketException("Socket is closed"); |
1374 return getImpl().getOption(name); |
1381 return getImpl().getOption(name); |
1375 } |
1382 } |
1376 |
1383 |
1377 private static Set<SocketOption<?>> options; |
1384 private static Set<SocketOption<?>> options; |
1378 private static boolean optionsSet = false; |
1385 private static boolean optionsSet = false; |