equal
deleted
inserted
replaced
579 * @throws SocketTimeoutException if timeout expires before connecting |
579 * @throws SocketTimeoutException if timeout expires before connecting |
580 * @throws java.nio.channels.IllegalBlockingModeException |
580 * @throws java.nio.channels.IllegalBlockingModeException |
581 * if this socket has an associated channel, |
581 * if this socket has an associated channel, |
582 * and the channel is in non-blocking mode |
582 * and the channel is in non-blocking mode |
583 * @throws IllegalArgumentException if endpoint is null or is a |
583 * @throws IllegalArgumentException if endpoint is null or is a |
584 * SocketAddress subclass not supported by this socket |
584 * SocketAddress subclass not supported by this socket, or |
|
585 * if {@code timeout} is negative |
585 * @since 1.4 |
586 * @since 1.4 |
586 * @spec JSR-51 |
587 * @spec JSR-51 |
587 */ |
588 */ |
588 public void connect(SocketAddress endpoint, int timeout) throws IOException { |
589 public void connect(SocketAddress endpoint, int timeout) throws IOException { |
589 if (endpoint == null) |
590 if (endpoint == null) |
1210 * prior to entering the blocking operation to have effect. The |
1211 * prior to entering the blocking operation to have effect. The |
1211 * timeout must be {@code > 0}. |
1212 * timeout must be {@code > 0}. |
1212 * A timeout of zero is interpreted as an infinite timeout. |
1213 * A timeout of zero is interpreted as an infinite timeout. |
1213 * |
1214 * |
1214 * @param timeout the specified timeout, in milliseconds. |
1215 * @param timeout the specified timeout, in milliseconds. |
1215 * @exception SocketException if there is an error |
1216 * @throws SocketException if there is an error in the underlying protocol, |
1216 * in the underlying protocol, such as a TCP error. |
1217 * such as a TCP error |
|
1218 * @throws IllegalArgumentException if {@code timeout} is negative |
1217 * @since 1.1 |
1219 * @since 1.1 |
1218 * @see #getSoTimeout() |
1220 * @see #getSoTimeout() |
1219 */ |
1221 */ |
1220 public synchronized void setSoTimeout(int timeout) throws SocketException { |
1222 public synchronized void setSoTimeout(int timeout) throws SocketException { |
1221 if (isClosed()) |
1223 if (isClosed()) |
1222 throw new SocketException("Socket is closed"); |
1224 throw new SocketException("Socket is closed"); |
1223 if (timeout < 0) |
1225 if (timeout < 0) |
1224 throw new IllegalArgumentException("timeout < 0"); |
1226 throw new IllegalArgumentException("timeout can't be negative"); |
1225 |
1227 |
1226 getImpl().setOption(SocketOptions.SO_TIMEOUT, timeout); |
1228 getImpl().setOption(SocketOptions.SO_TIMEOUT, timeout); |
1227 } |
1229 } |
1228 |
1230 |
1229 /** |
1231 /** |