140 * request to connect) is set to the {@code backlog} parameter. If
141 * a connection indication arrives when the queue is full, the
142 * connection is refused.
143 * <p>
144 * If the application has specified a server socket factory, that
145 * factory's {@code createSocketImpl} method is called to create
146 * the actual socket implementation. Otherwise a "plain" socket is created.
147 * <p>
148 * If there is a security manager,
149 * its {@code checkListen} method is called
150 * with the {@code port} argument
151 * as its argument to ensure the operation is allowed.
152 * This could result in a SecurityException.
153 *
154 * The {@code backlog} argument is the requested maximum number of
155 * pending connections on the socket. Its exact semantics are implementation
156 * specific. In particular, an implementation may impose a maximum length
157 * or may choose to ignore the parameter altogther. The value provided
158 * should be greater than {@code 0}. If it is less than or equal to
159 * {@code 0}, then an implementation specific default will be used.
160 * <P>
161 *
162 * @param port the port number, or {@code 0} to use a port
163 * number that is automatically allocated.
164 * @param backlog requested maximum length of the queue of incoming
165 * connections.
166 *
167 * @exception IOException if an I/O error occurs when opening the socket.
168 * @exception SecurityException
169 * if a security manager exists and its {@code checkListen}
170 * method doesn't allow the operation.
171 * @exception IllegalArgumentException if the port parameter is outside
172 * the specified range of valid port values, which is between
173 * 0 and 65535, inclusive.
174 *
175 * @see java.net.SocketImpl
176 * @see java.net.SocketImplFactory#createSocketImpl()
177 * @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory)
178 * @see SecurityManager#checkListen
179 */
180 public ServerSocket(int port, int backlog) throws IOException {
189 * If <i>bindAddr</i> is null, it will default accepting
190 * connections on any/all local addresses.
191 * The port must be between 0 and 65535, inclusive.
192 * A port number of {@code 0} means that the port number is
193 * automatically allocated, typically from an ephemeral port range.
194 * This port number can then be retrieved by calling
195 * {@link #getLocalPort getLocalPort}.
196 *
197 * <P>If there is a security manager, this method
198 * calls its {@code checkListen} method
199 * with the {@code port} argument
200 * as its argument to ensure the operation is allowed.
201 * This could result in a SecurityException.
202 *
203 * The {@code backlog} argument is the requested maximum number of
204 * pending connections on the socket. Its exact semantics are implementation
205 * specific. In particular, an implementation may impose a maximum length
206 * or may choose to ignore the parameter altogther. The value provided
207 * should be greater than {@code 0}. If it is less than or equal to
208 * {@code 0}, then an implementation specific default will be used.
209 * <P>
210 * @param port the port number, or {@code 0} to use a port
211 * number that is automatically allocated.
212 * @param backlog requested maximum length of the queue of incoming
213 * connections.
214 * @param bindAddr the local InetAddress the server will bind to
215 *
216 * @throws SecurityException if a security manager exists and
217 * its {@code checkListen} method doesn't allow the operation.
218 *
219 * @throws IOException if an I/O error occurs when opening the socket.
220 * @exception IllegalArgumentException if the port parameter is outside
221 * the specified range of valid port values, which is between
222 * 0 and 65535, inclusive.
223 *
224 * @see SocketOptions
225 * @see SocketImpl
226 * @see SecurityManager#checkListen
227 * @since JDK1.1
228 */
229 public ServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException {
298 * @since 1.4
299 */
300 void createImpl() throws SocketException {
301 if (impl == null)
302 setImpl();
303 try {
304 impl.create(true);
305 created = true;
306 } catch (IOException e) {
307 throw new SocketException(e.getMessage());
308 }
309 }
310
311 /**
312 *
313 * Binds the {@code ServerSocket} to a specific address
314 * (IP address and port number).
315 * <p>
316 * If the address is {@code null}, then the system will pick up
317 * an ephemeral port and a valid local address to bind the socket.
318 * <p>
319 * @param endpoint The IP address and port number to bind to.
320 * @throws IOException if the bind operation fails, or if the socket
321 * is already bound.
322 * @throws SecurityException if a {@code SecurityManager} is present and
323 * its {@code checkListen} method doesn't allow the operation.
324 * @throws IllegalArgumentException if endpoint is a
325 * SocketAddress subclass not supported by this socket
326 * @since 1.4
327 */
328 public void bind(SocketAddress endpoint) throws IOException {
329 bind(endpoint, 50);
330 }
331
332 /**
333 *
334 * Binds the {@code ServerSocket} to a specific address
335 * (IP address and port number).
336 * <p>
337 * If the address is {@code null}, then the system will pick up
338 * an ephemeral port and a valid local address to bind the socket.
|
140 * request to connect) is set to the {@code backlog} parameter. If
141 * a connection indication arrives when the queue is full, the
142 * connection is refused.
143 * <p>
144 * If the application has specified a server socket factory, that
145 * factory's {@code createSocketImpl} method is called to create
146 * the actual socket implementation. Otherwise a "plain" socket is created.
147 * <p>
148 * If there is a security manager,
149 * its {@code checkListen} method is called
150 * with the {@code port} argument
151 * as its argument to ensure the operation is allowed.
152 * This could result in a SecurityException.
153 *
154 * The {@code backlog} argument is the requested maximum number of
155 * pending connections on the socket. Its exact semantics are implementation
156 * specific. In particular, an implementation may impose a maximum length
157 * or may choose to ignore the parameter altogther. The value provided
158 * should be greater than {@code 0}. If it is less than or equal to
159 * {@code 0}, then an implementation specific default will be used.
160 *
161 * @param port the port number, or {@code 0} to use a port
162 * number that is automatically allocated.
163 * @param backlog requested maximum length of the queue of incoming
164 * connections.
165 *
166 * @exception IOException if an I/O error occurs when opening the socket.
167 * @exception SecurityException
168 * if a security manager exists and its {@code checkListen}
169 * method doesn't allow the operation.
170 * @exception IllegalArgumentException if the port parameter is outside
171 * the specified range of valid port values, which is between
172 * 0 and 65535, inclusive.
173 *
174 * @see java.net.SocketImpl
175 * @see java.net.SocketImplFactory#createSocketImpl()
176 * @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory)
177 * @see SecurityManager#checkListen
178 */
179 public ServerSocket(int port, int backlog) throws IOException {
188 * If <i>bindAddr</i> is null, it will default accepting
189 * connections on any/all local addresses.
190 * The port must be between 0 and 65535, inclusive.
191 * A port number of {@code 0} means that the port number is
192 * automatically allocated, typically from an ephemeral port range.
193 * This port number can then be retrieved by calling
194 * {@link #getLocalPort getLocalPort}.
195 *
196 * <P>If there is a security manager, this method
197 * calls its {@code checkListen} method
198 * with the {@code port} argument
199 * as its argument to ensure the operation is allowed.
200 * This could result in a SecurityException.
201 *
202 * The {@code backlog} argument is the requested maximum number of
203 * pending connections on the socket. Its exact semantics are implementation
204 * specific. In particular, an implementation may impose a maximum length
205 * or may choose to ignore the parameter altogther. The value provided
206 * should be greater than {@code 0}. If it is less than or equal to
207 * {@code 0}, then an implementation specific default will be used.
208 *
209 * @param port the port number, or {@code 0} to use a port
210 * number that is automatically allocated.
211 * @param backlog requested maximum length of the queue of incoming
212 * connections.
213 * @param bindAddr the local InetAddress the server will bind to
214 *
215 * @throws SecurityException if a security manager exists and
216 * its {@code checkListen} method doesn't allow the operation.
217 *
218 * @throws IOException if an I/O error occurs when opening the socket.
219 * @exception IllegalArgumentException if the port parameter is outside
220 * the specified range of valid port values, which is between
221 * 0 and 65535, inclusive.
222 *
223 * @see SocketOptions
224 * @see SocketImpl
225 * @see SecurityManager#checkListen
226 * @since JDK1.1
227 */
228 public ServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException {
297 * @since 1.4
298 */
299 void createImpl() throws SocketException {
300 if (impl == null)
301 setImpl();
302 try {
303 impl.create(true);
304 created = true;
305 } catch (IOException e) {
306 throw new SocketException(e.getMessage());
307 }
308 }
309
310 /**
311 *
312 * Binds the {@code ServerSocket} to a specific address
313 * (IP address and port number).
314 * <p>
315 * If the address is {@code null}, then the system will pick up
316 * an ephemeral port and a valid local address to bind the socket.
317 *
318 * @param endpoint The IP address and port number to bind to.
319 * @throws IOException if the bind operation fails, or if the socket
320 * is already bound.
321 * @throws SecurityException if a {@code SecurityManager} is present and
322 * its {@code checkListen} method doesn't allow the operation.
323 * @throws IllegalArgumentException if endpoint is a
324 * SocketAddress subclass not supported by this socket
325 * @since 1.4
326 */
327 public void bind(SocketAddress endpoint) throws IOException {
328 bind(endpoint, 50);
329 }
330
331 /**
332 *
333 * Binds the {@code ServerSocket} to a specific address
334 * (IP address and port number).
335 * <p>
336 * If the address is {@code null}, then the system will pick up
337 * an ephemeral port and a valid local address to bind the socket.
|