equal
deleted
inserted
replaced
897 * timeout must be {@code > 0}. |
897 * timeout must be {@code > 0}. |
898 * A timeout of zero is interpreted as an infinite timeout. |
898 * A timeout of zero is interpreted as an infinite timeout. |
899 * |
899 * |
900 * @param timeout the specified timeout in milliseconds. |
900 * @param timeout the specified timeout in milliseconds. |
901 * @throws SocketException if there is an error in the underlying protocol, such as an UDP error. |
901 * @throws SocketException if there is an error in the underlying protocol, such as an UDP error. |
|
902 * @throws IllegalArgumentException if {@code timeout} is negative |
902 * @since 1.1 |
903 * @since 1.1 |
903 * @see #getSoTimeout() |
904 * @see #getSoTimeout() |
904 */ |
905 */ |
905 public synchronized void setSoTimeout(int timeout) throws SocketException { |
906 public synchronized void setSoTimeout(int timeout) throws SocketException { |
906 if (isClosed()) |
907 if (isClosed()) |
907 throw new SocketException("Socket is closed"); |
908 throw new SocketException("Socket is closed"); |
|
909 if (timeout < 0) |
|
910 throw new IllegalArgumentException("timeout < 0"); |
908 getImpl().setOption(SocketOptions.SO_TIMEOUT, timeout); |
911 getImpl().setOption(SocketOptions.SO_TIMEOUT, timeout); |
909 } |
912 } |
910 |
913 |
911 /** |
914 /** |
912 * Retrieve setting for SO_TIMEOUT. 0 returns implies that the |
915 * Retrieve setting for SO_TIMEOUT. 0 returns implies that the |