Skip to content

Commit 635cb3c

Browse files
committed
8329745: Update the documentation of ServerSocket and Socket to refer to StandardSocketOptions instead of legacy SocketOptions
Reviewed-by: alanb, dfuchs
1 parent 5c9f036 commit 635cb3c

File tree

2 files changed

+94
-105
lines changed

2 files changed

+94
-105
lines changed

src/java.base/share/classes/java/net/ServerSocket.java

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -140,9 +140,10 @@ public ServerSocket() throws IOException {
140140
* request to connect) is set to {@code 50}. If a connection
141141
* indication arrives when the queue is full, the connection is refused.
142142
* <p>
143-
* If the application has specified a server socket implementation
144-
* factory, that factory's {@code createSocketImpl} method is called to
145-
* create the actual socket implementation. Otherwise a system-default
143+
* If the application has specified a {@linkplain SocketImplFactory server
144+
* socket implementation factory}, that factory's
145+
* {@linkplain SocketImplFactory#createSocketImpl() createSocketImpl} method
146+
* is called to create the actual socket implementation. Otherwise a system-default
146147
* socket implementation is created.
147148
* <p>
148149
* If there is a security manager,
@@ -163,7 +164,6 @@ public ServerSocket() throws IOException {
163164
* the specified range of valid port values, which is between
164165
* 0 and 65535, inclusive.
165166
*
166-
* @see java.net.SocketImpl
167167
* @see SecurityManager#checkListen
168168
*/
169169
public ServerSocket(int port) throws IOException {
@@ -183,9 +183,10 @@ public ServerSocket(int port) throws IOException {
183183
* a connection indication arrives when the queue is full, the
184184
* connection is refused.
185185
* <p>
186-
* If the application has specified a server socket implementation
187-
* factory, that factory's {@code createSocketImpl} method is called to
188-
* create the actual socket implementation. Otherwise a system-default
186+
* If the application has specified a {@linkplain SocketImplFactory server
187+
* socket implementation factory}, that factory's
188+
* {@linkplain SocketImplFactory#createSocketImpl() createSocketImpl} method
189+
* is called to create the actual socket implementation. Otherwise a system-default
189190
* socket implementation is created.
190191
* <p>
191192
* If there is a security manager,
@@ -214,7 +215,6 @@ public ServerSocket(int port) throws IOException {
214215
* the specified range of valid port values, which is between
215216
* 0 and 65535, inclusive.
216217
*
217-
* @see java.net.SocketImpl
218218
* @see SecurityManager#checkListen
219219
*/
220220
public ServerSocket(int port, int backlog) throws IOException {
@@ -261,8 +261,6 @@ public ServerSocket(int port, int backlog) throws IOException {
261261
* the specified range of valid port values, which is between
262262
* 0 and 65535, inclusive.
263263
*
264-
* @see SocketOptions
265-
* @see SocketImpl
266264
* @see SecurityManager#checkListen
267265
* @since 1.1
268266
*/
@@ -801,7 +799,7 @@ public boolean isClosed() {
801799
* specified timeout, in milliseconds. With this option set to a positive
802800
* timeout value, a call to accept() for this ServerSocket
803801
* will block for only this amount of time. If the timeout expires,
804-
* a <B>java.net.SocketTimeoutException</B> is raised, though the
802+
* a {@link java.net.SocketTimeoutException} is raised, though the
805803
* ServerSocket is still valid. A timeout of zero is interpreted as an
806804
* infinite timeout.
807805
* The option <B>must</B> be enabled prior to entering the blocking
@@ -843,7 +841,7 @@ public int getSoTimeout() throws IOException {
843841
}
844842

845843
/**
846-
* Enable/disable the {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}
844+
* Enable/disable the {@link StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR}
847845
* socket option.
848846
* <p>
849847
* When a TCP connection is closed the connection may remain
@@ -855,22 +853,22 @@ public int getSoTimeout() throws IOException {
855853
* {@code SocketAddress} if there is a connection in the
856854
* timeout state involving the socket address or port.
857855
* <p>
858-
* Enabling {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} prior to
859-
* binding the socket using {@link #bind(SocketAddress)} allows the socket
860-
* to be bound even though a previous connection is in a timeout state.
856+
* Enabling {@code SO_REUSEADDR} prior to binding the socket using
857+
* {@link #bind(SocketAddress)} allows the socket to be bound even
858+
* though a previous connection is in a timeout state.
861859
* <p>
862860
* When a {@code ServerSocket} is created the initial setting
863-
* of {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is not defined.
864-
* Applications can use {@link #getReuseAddress()} to determine the initial
865-
* setting of {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}.
861+
* of {@code SO_REUSEADDR} is not defined. Applications can use
862+
* {@link #getReuseAddress()} to determine the initial
863+
* setting of {@code SO_REUSEADDR}.
866864
* <p>
867-
* The behaviour when {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is
868-
* enabled or disabled after a socket is bound (See {@link #isBound()})
865+
* The behaviour when {@code SO_REUSEADDR} is enabled or disabled
866+
* after a socket is bound (See {@link #isBound()})
869867
* is not defined.
870868
*
871869
* @param on whether to enable or disable the socket option
872870
* @throws SocketException if an error occurs enabling or
873-
* disabling the {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}
871+
* disabling the {@code SO_REUSEADDR}
874872
* socket option, or the socket is closed.
875873
* @since 1.4
876874
* @see #getReuseAddress()
@@ -885,10 +883,10 @@ public void setReuseAddress(boolean on) throws SocketException {
885883
}
886884

887885
/**
888-
* Tests if {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is enabled.
886+
* Tests if {@link StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} is enabled.
889887
*
890888
* @return a {@code boolean} indicating whether or not
891-
* {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is enabled.
889+
* {@code SO_REUSEADDR} is enabled.
892890
* @throws SocketException if there is an error
893891
* in the underlying protocol, such as a TCP error.
894892
* @since 1.4
@@ -981,14 +979,14 @@ public static synchronized void setSocketFactory(SocketImplFactory fac) throws I
981979

982980
/**
983981
* Sets a default proposed value for the
984-
* {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option for sockets
982+
* {@link StandardSocketOptions#SO_RCVBUF SO_RCVBUF} option for sockets
985983
* accepted from this {@code ServerSocket}. The value actually set
986984
* in the accepted socket must be determined by calling
987985
* {@link Socket#getReceiveBufferSize()} after the socket
988986
* is returned by {@link #accept()}.
989987
* <p>
990-
* The value of {@link SocketOptions#SO_RCVBUF SO_RCVBUF} is used both to
991-
* set the size of the internal socket receive buffer, and to set the size
988+
* The value of {@code SO_RCVBUF} is used both to set the size of
989+
* the internal socket receive buffer, and to set the size
992990
* of the TCP receive window that is advertised to the remote peer.
993991
* <p>
994992
* It is possible to change the value subsequently, by calling
@@ -1024,14 +1022,13 @@ public void setReceiveBufferSize(int size) throws SocketException {
10241022
}
10251023

10261024
/**
1027-
* Gets the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option
1025+
* Gets the value of the {@link StandardSocketOptions#SO_RCVBUF SO_RCVBUF} option
10281026
* for this {@code ServerSocket}, that is the proposed buffer size that
10291027
* will be used for Sockets accepted from this {@code ServerSocket}.
10301028
*
10311029
* <p>Note, the value actually set in the accepted socket is determined by
10321030
* calling {@link Socket#getReceiveBufferSize()}.
1033-
* @return the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF}
1034-
* option for this {@code Socket}.
1031+
* @return the value of the {@code SO_RCVBUF} option for this {@code Socket}.
10351032
* @throws SocketException if there is an error
10361033
* in the underlying protocol, such as a TCP error.
10371034
* @see #setReceiveBufferSize(int)

0 commit comments

Comments
 (0)