@@ -683,7 +683,8 @@ void setConnected() {
683
683
* </ol>
684
684
*
685
685
* @param endpoint the {@code SocketAddress}
686
- * @throws IOException if an error occurs during the connection
686
+ * @throws IOException if an error occurs during the connection, the socket
687
+ * is already connected or the socket is closed
687
688
* @throws java.nio.channels.IllegalBlockingModeException
688
689
* if this socket has an associated channel,
689
690
* and the channel is in non-blocking mode
@@ -717,7 +718,8 @@ public void connect(SocketAddress endpoint) throws IOException {
717
718
*
718
719
* @param endpoint the {@code SocketAddress}
719
720
* @param timeout the timeout value to be used in milliseconds.
720
- * @throws IOException if an error occurs during the connection
721
+ * @throws IOException if an error occurs during the connection, the socket
722
+ * is already connected or the socket is closed
721
723
* @throws SocketTimeoutException if timeout expires before connecting
722
724
* @throws java.nio.channels.IllegalBlockingModeException
723
725
* if this socket has an associated channel,
@@ -780,8 +782,8 @@ public void connect(SocketAddress endpoint, int timeout) throws IOException {
780
782
* an ephemeral port and a valid local address to bind the socket.
781
783
*
782
784
* @param bindpoint the {@code SocketAddress} to bind to
783
- * @throws IOException if the bind operation fails, or if the socket
784
- * is already bound .
785
+ * @throws IOException if the bind operation fails, the socket
786
+ * is already bound or the socket is closed .
785
787
* @throws IllegalArgumentException if bindpoint is a
786
788
* SocketAddress subclass not supported by this socket
787
789
* @throws SecurityException if a security manager exists and its
@@ -1174,8 +1176,8 @@ public void close() throws IOException {
1174
1176
* will close the associated socket.
1175
1177
*
1176
1178
* @return an output stream for writing bytes to this socket.
1177
- * @throws IOException if an I/O error occurs when creating the
1178
- * output stream or if the socket is not connected .
1179
+ * @throws IOException if an I/O error occurs when creating the
1180
+ * output stream, the socket is not connected or the socket is closed .
1179
1181
*/
1180
1182
public OutputStream getOutputStream () throws IOException {
1181
1183
int s = state ;
@@ -1251,8 +1253,8 @@ public void close() throws IOException {
1251
1253
* @param on {@code true} to enable {@code TCP_NODELAY},
1252
1254
* {@code false} to disable.
1253
1255
*
1254
- * @throws SocketException if there is an error
1255
- * in the underlying protocol, such as a TCP error.
1256
+ * @throws SocketException if there is an error in the underlying protocol,
1257
+ * such as a TCP error, or the socket is closed .
1256
1258
*
1257
1259
* @since 1.1
1258
1260
*
@@ -1269,8 +1271,8 @@ public void setTcpNoDelay(boolean on) throws SocketException {
1269
1271
*
1270
1272
* @return a {@code boolean} indicating whether or not
1271
1273
* {@code TCP_NODELAY} is enabled.
1272
- * @throws SocketException if there is an error
1273
- * in the underlying protocol, such as a TCP error.
1274
+ * @throws SocketException if there is an error in the underlying protocol,
1275
+ * such as a TCP error, or the socket is closed .
1274
1276
* @since 1.1
1275
1277
* @see #setTcpNoDelay(boolean)
1276
1278
*/
@@ -1289,9 +1291,9 @@ public boolean getTcpNoDelay() throws SocketException {
1289
1291
*
1290
1292
* @param on whether or not to linger on.
1291
1293
* @param linger how long to linger for, if on is true.
1292
- * @throws SocketException if there is an error
1293
- * in the underlying protocol, such as a TCP error.
1294
- * @throws IllegalArgumentException if the linger value is negative.
1294
+ * @throws SocketException if there is an error in the underlying protocol,
1295
+ * such as a TCP error, or the socket is closed .
1296
+ * @throws IllegalArgumentException if the linger value is negative.
1295
1297
* @since 1.1
1296
1298
* @see #getSoLinger()
1297
1299
*/
@@ -1318,8 +1320,8 @@ public void setSoLinger(boolean on, int linger) throws SocketException {
1318
1320
* The setting only affects socket close.
1319
1321
*
1320
1322
* @return the setting for {@code SO_LINGER}.
1321
- * @throws SocketException if there is an error
1322
- * in the underlying protocol, such as a TCP error.
1323
+ * @throws SocketException if there is an error in the underlying protocol,
1324
+ * such as a TCP error, or the socket is closed .
1323
1325
* @since 1.1
1324
1326
* @see #setSoLinger(boolean, int)
1325
1327
*/
@@ -1368,8 +1370,8 @@ public void sendUrgentData(int data) throws IOException {
1368
1370
* @param on {@code true} to enable {@code SO_OOBINLINE},
1369
1371
* {@code false} to disable.
1370
1372
*
1371
- * @throws SocketException if there is an error
1372
- * in the underlying protocol, such as a TCP error.
1373
+ * @throws SocketException if there is an error in the underlying protocol,
1374
+ * such as a TCP error, or the socket is closed .
1373
1375
*
1374
1376
* @since 1.4
1375
1377
*
@@ -1387,8 +1389,8 @@ public void setOOBInline(boolean on) throws SocketException {
1387
1389
* @return a {@code boolean} indicating whether or not
1388
1390
* {@code SO_OOBINLINE} is enabled.
1389
1391
*
1390
- * @throws SocketException if there is an error
1391
- * in the underlying protocol, such as a TCP error.
1392
+ * @throws SocketException if there is an error in the underlying protocol,
1393
+ * such as a TCP error, or the socket is closed .
1392
1394
* @since 1.4
1393
1395
* @see #setOOBInline(boolean)
1394
1396
*/
@@ -1409,8 +1411,8 @@ public boolean getOOBInline() throws SocketException {
1409
1411
* to have effect.
1410
1412
*
1411
1413
* @param timeout the specified timeout, in milliseconds.
1412
- * @throws SocketException if there is an error in the underlying protocol,
1413
- * such as a TCP error
1414
+ * @throws SocketException if there is an error in the underlying protocol,
1415
+ * such as a TCP error, or the socket is closed.
1414
1416
* @throws IllegalArgumentException if {@code timeout} is negative
1415
1417
* @since 1.1
1416
1418
* @see #getSoTimeout()
@@ -1428,8 +1430,8 @@ public void setSoTimeout(int timeout) throws SocketException {
1428
1430
* 0 returns implies that the option is disabled (i.e., timeout of infinity).
1429
1431
*
1430
1432
* @return the setting for {@code SO_TIMEOUT}
1431
- * @throws SocketException if there is an error
1432
- * in the underlying protocol, such as a TCP error.
1433
+ * @throws SocketException if there is an error in the underlying protocol,
1434
+ * such as a TCP error, or the socket is closed .
1433
1435
*
1434
1436
* @since 1.1
1435
1437
* @see #setSoTimeout(int)
@@ -1455,14 +1457,12 @@ public int getSoTimeout() throws SocketException {
1455
1457
* <p>Because {@code SO_SNDBUF} is a hint, applications that want to verify
1456
1458
* what size the buffers were set to should call {@link #getSendBufferSize()}.
1457
1459
*
1458
- * @throws SocketException if there is an error
1459
- * in the underlying protocol, such as a TCP error.
1460
- *
1461
1460
* @param size the size to which to set the send buffer
1462
1461
* size. This value must be greater than 0.
1463
1462
*
1464
- * @throws IllegalArgumentException if the
1465
- * value is 0 or is negative.
1463
+ * @throws SocketException if there is an error in the underlying protocol,
1464
+ * such as a TCP error, or the socket is closed.
1465
+ * @throws IllegalArgumentException if the value is 0 or is negative.
1466
1466
*
1467
1467
* @see #getSendBufferSize()
1468
1468
* @since 1.2
@@ -1481,8 +1481,8 @@ public void setSendBufferSize(int size) throws SocketException {
1481
1481
* for output on this {@code Socket}.
1482
1482
* @return the value of the {@code SO_SNDBUF} option for this {@code Socket}.
1483
1483
*
1484
- * @throws SocketException if there is an error
1485
- * in the underlying protocol, such as a TCP error.
1484
+ * @throws SocketException if there is an error in the underlying protocol,
1485
+ * such as a TCP error, or the socket is closed .
1486
1486
*
1487
1487
* @see #setSendBufferSize(int)
1488
1488
* @since 1.2
@@ -1529,8 +1529,8 @@ public int getSendBufferSize() throws SocketException {
1529
1529
* @throws IllegalArgumentException if the value is 0 or is
1530
1530
* negative.
1531
1531
*
1532
- * @throws SocketException if there is an error
1533
- * in the underlying protocol, such as a TCP error.
1532
+ * @throws SocketException if there is an error in the underlying protocol,
1533
+ * such as a TCP error, or the socket is closed .
1534
1534
*
1535
1535
* @see #getReceiveBufferSize()
1536
1536
* @see ServerSocket#setReceiveBufferSize(int)
@@ -1550,8 +1550,8 @@ public void setReceiveBufferSize(int size) throws SocketException {
1550
1550
* for input on this {@code Socket}.
1551
1551
*
1552
1552
* @return the value of the {@code SO_RCVBUF} option for this {@code Socket}.
1553
- * @throws SocketException if there is an error
1554
- * in the underlying protocol, such as a TCP error.
1553
+ * @throws SocketException if there is an error in the underlying protocol,
1554
+ * such as a TCP error, or the socket is closed .
1555
1555
* @see #setReceiveBufferSize(int)
1556
1556
* @since 1.2
1557
1557
*/
@@ -1570,8 +1570,8 @@ public int getReceiveBufferSize() throws SocketException {
1570
1570
* Enable/disable {@link StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE}.
1571
1571
*
1572
1572
* @param on whether or not to have socket keep alive turned on.
1573
- * @throws SocketException if there is an error
1574
- * in the underlying protocol, such as a TCP error.
1573
+ * @throws SocketException if there is an error in the underlying protocol,
1574
+ * such as a TCP error, or the socket is closed .
1575
1575
* @since 1.3
1576
1576
* @see #getKeepAlive()
1577
1577
*/
@@ -1586,8 +1586,8 @@ public void setKeepAlive(boolean on) throws SocketException {
1586
1586
*
1587
1587
* @return a {@code boolean} indicating whether or not
1588
1588
* {@code SO_KEEPALIVE} is enabled.
1589
- * @throws SocketException if there is an error
1590
- * in the underlying protocol, such as a TCP error.
1589
+ * @throws SocketException if there is an error in the underlying protocol,
1590
+ * such as a TCP error, or the socket is closed .
1591
1591
* @since 1.3
1592
1592
* @see #setKeepAlive(boolean)
1593
1593
*/
@@ -1637,8 +1637,8 @@ public boolean getKeepAlive() throws SocketException {
1637
1637
* would be placed into the sin6_flowinfo field of the IP header.
1638
1638
*
1639
1639
* @param tc an {@code int} value for the bitset.
1640
- * @throws SocketException if there is an error setting the
1641
- * traffic class or type-of-service
1640
+ * @throws SocketException if there is an error setting the traffic class or type-of-service,
1641
+ * or the socket is closed.
1642
1642
* @since 1.4
1643
1643
* @see #getTrafficClass
1644
1644
* @see StandardSocketOptions#IP_TOS
@@ -1661,8 +1661,8 @@ public void setTrafficClass(int tc) throws SocketException {
1661
1661
* set using the {@link #setTrafficClass(int)} method on this Socket.
1662
1662
*
1663
1663
* @return the traffic class or type-of-service already set
1664
- * @throws SocketException if there is an error obtaining the
1665
- * traffic class or type-of-service value.
1664
+ * @throws SocketException if there is an error obtaining the traffic class
1665
+ * or type-of-service value, or the socket is closed .
1666
1666
* @since 1.4
1667
1667
* @see #setTrafficClass(int)
1668
1668
* @see StandardSocketOptions#IP_TOS
@@ -1715,8 +1715,8 @@ public void setReuseAddress(boolean on) throws SocketException {
1715
1715
*
1716
1716
* @return a {@code boolean} indicating whether or not
1717
1717
* {@code SO_REUSEADDR} is enabled.
1718
- * @throws SocketException if there is an error
1719
- * in the underlying protocol, such as a TCP error.
1718
+ * @throws SocketException if there is an error in the underlying protocol,
1719
+ * such as a TCP error, or the socket is closed .
1720
1720
* @since 1.4
1721
1721
* @see #setReuseAddress(boolean)
1722
1722
*/
@@ -1733,8 +1733,9 @@ public boolean getReuseAddress() throws SocketException {
1733
1733
* will throw a {@link SocketException}.
1734
1734
* <p>
1735
1735
* Once a socket has been closed, it is not available for further networking
1736
- * use (i.e. can't be reconnected or rebound). A new socket needs to be
1737
- * created.
1736
+ * use (i.e. can't be reconnected or rebound) and several of the methods defined
1737
+ * by this class will throw an exception if invoked on the closed socket. A new
1738
+ * socket needs to be created.
1738
1739
*
1739
1740
* <p> Closing this socket will also close the socket's
1740
1741
* {@link java.io.InputStream InputStream} and
@@ -1767,8 +1768,8 @@ public void close() throws IOException {
1767
1768
* socket, the stream's {@code available} method will return 0, and its
1768
1769
* {@code read} methods will return {@code -1} (end of stream).
1769
1770
*
1770
- * @throws IOException if an I/O error occurs when shutting down this
1771
- * socket.
1771
+ * @throws IOException if an I/O error occurs when shutting down this socket, the
1772
+ * socket is not connected or the socket is closed .
1772
1773
*
1773
1774
* @since 1.3
1774
1775
* @see java.net.Socket#shutdownOutput()
@@ -1797,8 +1798,8 @@ public void shutdownInput() throws IOException {
1797
1798
* shutdownOutput() on the socket, the stream will throw
1798
1799
* an IOException.
1799
1800
*
1800
- * @throws IOException if an I/O error occurs when shutting down this
1801
- * socket.
1801
+ * @throws IOException if an I/O error occurs when shutting down this socket, the socket
1802
+ * is not connected or the socket is closed .
1802
1803
*
1803
1804
* @since 1.3
1804
1805
* @see java.net.Socket#shutdownInput()
0 commit comments