mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8219446: Specify behaviour of timeout accepting methods of Socket and ServerSocket if timeout is negative
Reviewed-by: alanb, dfuchs
This commit is contained in:
parent
75dd3985ca
commit
1933437f12
3 changed files with 13 additions and 12 deletions
|
@ -749,14 +749,17 @@ class ServerSocket implements java.io.Closeable {
|
|||
* timeout must be {@code > 0}.
|
||||
* A timeout of zero is interpreted as an infinite timeout.
|
||||
* @param timeout the specified timeout, in milliseconds
|
||||
* @exception SocketException if there is an error in
|
||||
* the underlying protocol, such as a TCP error.
|
||||
* @throws SocketException if there is an error in the underlying protocol,
|
||||
* such as a TCP error
|
||||
* @throws IllegalArgumentException if {@code timeout} is negative
|
||||
* @since 1.1
|
||||
* @see #getSoTimeout()
|
||||
*/
|
||||
public synchronized void setSoTimeout(int timeout) throws SocketException {
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket is closed");
|
||||
if (timeout < 0)
|
||||
throw new IllegalArgumentException("timeout < 0");
|
||||
getImpl().setOption(SocketOptions.SO_TIMEOUT, timeout);
|
||||
}
|
||||
|
||||
|
|
|
@ -581,7 +581,8 @@ class Socket implements java.io.Closeable {
|
|||
* if this socket has an associated channel,
|
||||
* and the channel is in non-blocking mode
|
||||
* @throws IllegalArgumentException if endpoint is null or is a
|
||||
* SocketAddress subclass not supported by this socket
|
||||
* SocketAddress subclass not supported by this socket, or
|
||||
* if {@code timeout} is negative
|
||||
* @since 1.4
|
||||
* @spec JSR-51
|
||||
*/
|
||||
|
@ -1212,8 +1213,9 @@ class Socket implements java.io.Closeable {
|
|||
* A timeout of zero is interpreted as an infinite timeout.
|
||||
*
|
||||
* @param timeout the specified timeout, in milliseconds.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @throws SocketException if there is an error in the underlying protocol,
|
||||
* such as a TCP error
|
||||
* @throws IllegalArgumentException if {@code timeout} is negative
|
||||
* @since 1.1
|
||||
* @see #getSoTimeout()
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue