mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8235141: Specify the required standard socket options for the socket types in the java.net package
Reviewed-by: alanb, chegar
This commit is contained in:
parent
2c772c7887
commit
7135b5dd9c
5 changed files with 340 additions and 5 deletions
|
@ -43,24 +43,69 @@ import java.util.Collections;
|
|||
* any order.
|
||||
*
|
||||
* <p> 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.
|
||||
* <p>
|
||||
* Example:
|
||||
* {@code
|
||||
* <pre>{@code
|
||||
* DatagramSocket s = new DatagramSocket(null);
|
||||
* s.bind(new InetSocketAddress(8888));
|
||||
* }
|
||||
* }</pre>
|
||||
* Which is equivalent to:
|
||||
* {@code
|
||||
* <pre>{@code
|
||||
* DatagramSocket s = new DatagramSocket(8888);
|
||||
* }
|
||||
* }</pre>
|
||||
* Both cases will create a DatagramSocket able to receive broadcasts on
|
||||
* UDP port 8888.
|
||||
*
|
||||
* <p> The {@code DatagramSocket} class defines convenience
|
||||
* methods to set and get several socket options. This class also
|
||||
* defines the {@link #setOption(SocketOption,Object) setOption}
|
||||
* and {@link #getOption(SocketOption) getOption} methods to set
|
||||
* and query socket options.
|
||||
* A {@code DatagramSocket} supports the following socket options:
|
||||
* <blockquote>
|
||||
* <a id="SocketOptions"></a>
|
||||
* <table class="striped">
|
||||
* <caption style="display:none">Socket options</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th scope="col">Option Name</th>
|
||||
* <th scope="col">Description</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </th>
|
||||
* <td> The size of the socket send buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
|
||||
* <td> The size of the socket receive buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
|
||||
* <td> Re-use address </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_BROADCAST SO_BROADCAST} </th>
|
||||
* <td> Allow transmission of broadcast datagrams </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#IP_TOS IP_TOS} </th>
|
||||
* <td> The Type of Service (ToS) octet in the Internet Protocol (IP) header </td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* An implementation may also support additional options. In particular an implementation
|
||||
* may support <a href="MulticastSocket.html#MulticastOptions">multicast options</a> 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
|
||||
|
|
|
@ -80,6 +80,46 @@ import java.util.Set;
|
|||
* <B>Multiple MulticastSockets</B> may subscribe to a multicast group
|
||||
* and port concurrently, and they will all receive group datagrams.
|
||||
*
|
||||
* <p> The {@code DatagramSocket} and {@code MulticastSocket}
|
||||
* classes define convenience methods to set and get several
|
||||
* socket options. Like {@code DatagramSocket} this class also
|
||||
* supports the {@link #setOption(SocketOption, Object) setOption}
|
||||
* and {@link #getOption(SocketOption) getOption} methods to set
|
||||
* and query socket options.
|
||||
* In addition to the socket options supported by
|
||||
* <a href="DatagramSocket.html#SocketOptions">{@code DatagramSocket}</a>, a
|
||||
* {@code MulticastSocket} supports the following socket options:
|
||||
* <blockquote>
|
||||
* <a id="MulticastOptions"></a>
|
||||
* <table class="striped">
|
||||
* <caption style="display:none">Socket options</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th scope="col">Option Name</th>
|
||||
* <th scope="col">Description</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#IP_MULTICAST_IF IP_MULTICAST_IF} </th>
|
||||
* <td> The network interface for Internet Protocol (IP) multicast datagrams </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#IP_MULTICAST_TTL
|
||||
* IP_MULTICAST_TTL} </th>
|
||||
* <td> The <em>time-to-live</em> for Internet Protocol (IP) multicast
|
||||
* datagrams </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP
|
||||
* IP_MULTICAST_LOOP} </th>
|
||||
* <td> Loopback for Internet Protocol (IP) multicast datagrams </td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* Additional (implementation specific) options may also be supported.
|
||||
*
|
||||
* @author Pavani Diwanji
|
||||
* @since 1.1
|
||||
*/
|
||||
|
|
|
@ -46,6 +46,35 @@ import sun.net.PlatformSocketImpl;
|
|||
* implementation to configure itself to create sockets
|
||||
* appropriate to the local firewall.
|
||||
*
|
||||
* <p> The {@code ServerSocket} class defines convenience
|
||||
* methods to set and get several socket options. This class also
|
||||
* defines the {@link #setOption(SocketOption, Object) setOption}
|
||||
* and {@link #getOption(SocketOption) getOption} methods to set
|
||||
* and query socket options.
|
||||
* A {@code ServerSocket} supports the following options:
|
||||
* <blockquote>
|
||||
* <table class="striped">
|
||||
* <caption style="display:none">Socket options</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th scope="col">Option Name</th>
|
||||
* <th scope="col">Description</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
|
||||
* <td> The size of the socket receive buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
|
||||
* <td> Re-use address </td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* Additional (implementation specific) options may also be supported.
|
||||
*
|
||||
* @author unascribed
|
||||
* @see java.net.SocketImpl
|
||||
* @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory)
|
||||
|
|
|
@ -50,6 +50,52 @@ import java.util.Collections;
|
|||
* can configure itself to create sockets appropriate to the local
|
||||
* firewall.
|
||||
*
|
||||
* <p> The {@code Socket} class defines convenience
|
||||
* methods to set and get several socket options. This class also
|
||||
* defines the {@link #setOption(SocketOption, Object) setOption}
|
||||
* and {@link #getOption(SocketOption) getOption} methods to set
|
||||
* and query socket options.
|
||||
* A {@code Socket} support the following options:
|
||||
* <blockquote>
|
||||
* <table class="striped">
|
||||
* <caption style="display:none">Socket options</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th scope="col">Option Name</th>
|
||||
* <th scope="col">Description</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </th>
|
||||
* <td> The size of the socket send buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
|
||||
* <td> The size of the socket receive buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} </th>
|
||||
* <td> Keep connection alive </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
|
||||
* <td> Re-use address </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#SO_LINGER SO_LINGER} </th>
|
||||
* <td> Linger on close if data is present (when configured in blocking mode
|
||||
* only) </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} </th>
|
||||
* <td> Disable the Nagle algorithm </td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* Additional (implementation specific) options may also be supported.
|
||||
*
|
||||
* @author unascribed
|
||||
* @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)
|
||||
* @see java.net.SocketImpl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue