--- old/src/java.base/share/classes/java/net/DatagramSocket.java 2019-12-02 15:01:43.000000000 +0000 +++ new/src/java.base/share/classes/java/net/DatagramSocket.java 2019-12-02 15:01:43.000000000 +0000 @@ -43,24 +43,69 @@ * any order. * *

Where possible, a newly constructed {@code DatagramSocket} has the - * {@link SocketOptions#SO_BROADCAST SO_BROADCAST} socket option enabled so as + * {@link StandardSocketOptions#SO_BROADCAST SO_BROADCAST} socket option enabled so as * to allow the transmission of broadcast datagrams. In order to receive * broadcast packets a DatagramSocket should be bound to the wildcard address. * In some implementations, broadcast packets may also be received when * a DatagramSocket is bound to a more specific address. *

* Example: - * {@code + *

{@code
  *              DatagramSocket s = new DatagramSocket(null);
  *              s.bind(new InetSocketAddress(8888));
- * }
+ * }
* Which is equivalent to: - * {@code + *
{@code
  *              DatagramSocket s = new DatagramSocket(8888);
- * }
+ * }
* Both cases will create a DatagramSocket able to receive broadcasts on * UDP port 8888. * + *

The {@code DatagramSocket} class offers some convenience methods + * (such as {@link #setReuseAddress(boolean) setReuseAddress}) + * to get and set some commonly used options. However, socket options + * can be more generally configured using the + * {@link #setOption(SocketOption,Object) setOption} method. + * A {@code DatagramSocket} supports the following socket options: + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Socket options
Option NameDescription
{@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} The size of the socket send buffer
{@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} The size of the socket receive buffer
{@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} Re-use address
{@link java.net.StandardSocketOptions#SO_BROADCAST SO_BROADCAST} Allow transmission of broadcast datagrams
{@link java.net.StandardSocketOptions#IP_TOS IP_TOS} The Type of Service (ToS) octet in the Internet Protocol (IP) header
+ *
+ * An implementation may also support additional options. In particular an implementation + * may support multicast options which + * can be useful when using a plain {@code DatagramSocket} to send datagrams to a + * multicast group. + * * @author Pavani Diwanji * @see java.net.DatagramPacket * @see java.nio.channels.DatagramChannel