< prev index next >

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

Print this page

 654      *             and connected address and packet address differ, or
 655      *             if the socket is not connected and the packet address
 656      *             is not set or if its port is <a href="#PortRange">out of
 657      *             range.</a>
 658      *
 659      * @see        java.net.DatagramPacket
 660      * @see        SecurityManager#checkMulticast(InetAddress)
 661      * @see        SecurityManager#checkConnect
 662      * @revised 1.4
 663      */
 664     public void send(DatagramPacket p) throws IOException  {
 665         delegate().send(p);
 666     }
 667 
 668     /**
 669      * Receives a datagram packet from this socket. When this method
 670      * returns, the {@code DatagramPacket}'s buffer is filled with
 671      * the data received. The datagram packet also contains the sender's
 672      * IP address, and the port number on the sender's machine.
 673      * <p>
 674      * This method blocks until a datagram is received. The
 675      * {@code length} field of the datagram packet object contains





 676      * the length of the received message. If the message is longer than
 677      * the packet's length, the message is truncated.
 678      * <p>
 679      * If there is a security manager, and the socket is not currently
 680      * connected to a remote address, a packet cannot be received if the
 681      * security manager's {@code checkAccept} method does not allow it.
 682      * Datagrams that are not permitted by the security manager are silently
 683      * discarded.
 684      *
 685      * @param      p   the {@code DatagramPacket} into which to place
 686      *                 the incoming data.
 687      * @throws     IOException  if an I/O error occurs.
 688      * @throws     SocketTimeoutException  if setSoTimeout was previously called
 689      *                 and the timeout has expired.
 690      * @throws     PortUnreachableException may be thrown if the socket is connected
 691      *             to a currently unreachable destination. Note, there is no guarantee that the
 692      *             exception will be thrown.
 693      * @throws     java.nio.channels.IllegalBlockingModeException
 694      *             if this socket has an associated channel,
 695      *             and the channel is in non-blocking mode.

 654      *             and connected address and packet address differ, or
 655      *             if the socket is not connected and the packet address
 656      *             is not set or if its port is <a href="#PortRange">out of
 657      *             range.</a>
 658      *
 659      * @see        java.net.DatagramPacket
 660      * @see        SecurityManager#checkMulticast(InetAddress)
 661      * @see        SecurityManager#checkConnect
 662      * @revised 1.4
 663      */
 664     public void send(DatagramPacket p) throws IOException  {
 665         delegate().send(p);
 666     }
 667 
 668     /**
 669      * Receives a datagram packet from this socket. When this method
 670      * returns, the {@code DatagramPacket}'s buffer is filled with
 671      * the data received. The datagram packet also contains the sender's
 672      * IP address, and the port number on the sender's machine.
 673      * <p>
 674      * This method blocks until a datagram is received.
 675      * For the system-default socket implementation at least, if a
 676      * {@linkplain Thread#isVirtual() virtual thread} blocked in {@code receive}
 677      * is {@linkplain Thread#interrupt() interrupted} then the socket is closed
 678      * and {@link SocketException} is thrown with the interrupt status set.
 679      * <p>
 680      * The {@code length} field of the datagram packet object contains
 681      * the length of the received message. If the message is longer than
 682      * the packet's length, the message is truncated.
 683      * <p>
 684      * If there is a security manager, and the socket is not currently
 685      * connected to a remote address, a packet cannot be received if the
 686      * security manager's {@code checkAccept} method does not allow it.
 687      * Datagrams that are not permitted by the security manager are silently
 688      * discarded.
 689      *
 690      * @param      p   the {@code DatagramPacket} into which to place
 691      *                 the incoming data.
 692      * @throws     IOException  if an I/O error occurs.
 693      * @throws     SocketTimeoutException  if setSoTimeout was previously called
 694      *                 and the timeout has expired.
 695      * @throws     PortUnreachableException may be thrown if the socket is connected
 696      *             to a currently unreachable destination. Note, there is no guarantee that the
 697      *             exception will be thrown.
 698      * @throws     java.nio.channels.IllegalBlockingModeException
 699      *             if this socket has an associated channel,
 700      *             and the channel is in non-blocking mode.
< prev index next >