1 /* |
1 /* |
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
263 * java.net.DatagramSocket} class. That is, if a security manager has been |
263 * java.net.DatagramSocket} class. That is, if a security manager has been |
264 * installed then this method verifies that its {@link |
264 * installed then this method verifies that its {@link |
265 * java.lang.SecurityManager#checkAccept checkAccept} and {@link |
265 * java.lang.SecurityManager#checkAccept checkAccept} and {@link |
266 * java.lang.SecurityManager#checkConnect checkConnect} methods permit |
266 * java.lang.SecurityManager#checkConnect checkConnect} methods permit |
267 * datagrams to be received from and sent to, respectively, the given |
267 * datagrams to be received from and sent to, respectively, the given |
268 * remote address. |
268 * remote address. Once connected, no further security checks are performed |
|
269 * for datagrams received from, or sent to, the given remote address. Care |
|
270 * should be taken to ensure that a connected datagram channel is not shared |
|
271 * with untrusted code. |
269 * |
272 * |
270 * <p> This method may be invoked at any time. It will not have any effect |
273 * <p> This method may be invoked at any time. It will not have any effect |
271 * on read or write operations that are already in progress at the moment |
274 * on read or write operations that are already in progress at the moment |
272 * that it is invoked. If this channel's socket is not bound then this method |
275 * that it is invoked. If this channel's socket is not bound then this method |
273 * will first cause the socket to be bound to an address that is assigned |
276 * will first cause the socket to be bound to an address that is assigned |
323 * that it is invoked. |
326 * that it is invoked. |
324 * |
327 * |
325 * <p> If this channel's socket is not connected, or if the channel is |
328 * <p> If this channel's socket is not connected, or if the channel is |
326 * closed, then invoking this method has no effect. </p> |
329 * closed, then invoking this method has no effect. </p> |
327 * |
330 * |
|
331 * @apiNote If this method throws an IOException, the channel's socket |
|
332 * may be left in an unspecified state. It is strongly recommended that |
|
333 * the channel be closed when disconnect fails. |
|
334 * |
328 * @return This datagram channel |
335 * @return This datagram channel |
329 * |
336 * |
330 * @throws IOException |
337 * @throws IOException |
331 * If some other I/O error occurs |
338 * If some other I/O error occurs |
332 */ |
339 */ |
367 * java.net.DatagramSocket#receive receive} method of the {@link |
374 * java.net.DatagramSocket#receive receive} method of the {@link |
368 * java.net.DatagramSocket} class. That is, if the socket is not connected |
375 * java.net.DatagramSocket} class. That is, if the socket is not connected |
369 * to a specific remote address and a security manager has been installed |
376 * to a specific remote address and a security manager has been installed |
370 * then for each datagram received this method verifies that the source's |
377 * then for each datagram received this method verifies that the source's |
371 * address and port number are permitted by the security manager's {@link |
378 * address and port number are permitted by the security manager's {@link |
372 * java.lang.SecurityManager#checkAccept checkAccept} method. The overhead |
379 * java.lang.SecurityManager#checkAccept checkAccept} method. Datagrams |
373 * of this security check can be avoided by first connecting the socket via |
380 * that are not permitted by the security manager are silently discarded. |
374 * the {@link #connect connect} method. |
381 * The overhead of this security check can be avoided by first connecting |
|
382 * the socket via the {@link #connect connect} method. |
375 * |
383 * |
376 * <p> This method may be invoked at any time. If another thread has |
384 * <p> This method may be invoked at any time. If another thread has |
377 * already initiated a read operation upon this channel, however, then an |
385 * already initiated a read operation upon this channel, however, then an |
378 * invocation of this method will block until the first operation is |
386 * invocation of this method will block until the first operation is |
379 * complete. If this channel's socket is not bound then this method will |
387 * complete. If this channel's socket is not bound then this method will |
398 * @throws ClosedByInterruptException |
406 * @throws ClosedByInterruptException |
399 * If another thread interrupts the current thread |
407 * If another thread interrupts the current thread |
400 * while the read operation is in progress, thereby |
408 * while the read operation is in progress, thereby |
401 * closing the channel and setting the current thread's |
409 * closing the channel and setting the current thread's |
402 * interrupt status |
410 * interrupt status |
403 * |
|
404 * @throws SecurityException |
|
405 * If a security manager has been installed |
|
406 * and it does not permit datagrams to be accepted |
|
407 * from the datagram's sender |
|
408 * |
411 * |
409 * @throws IOException |
412 * @throws IOException |
410 * If some other I/O error occurs |
413 * If some other I/O error occurs |
411 */ |
414 */ |
412 public abstract SocketAddress receive(ByteBuffer dst) throws IOException; |
415 public abstract SocketAddress receive(ByteBuffer dst) throws IOException; |