< prev index next >

src/java.base/share/classes/java/nio/channels/DatagramChannel.java

Print this page




  40  * <p> A datagram channel is created by invoking one of the {@link #open open} methods
  41  * of this class. It is not possible to create a channel for an arbitrary,
  42  * pre-existing datagram socket. A newly-created datagram channel is open but not
  43  * connected. A datagram channel need not be connected in order for the {@link #send
  44  * send} and {@link #receive receive} methods to be used.  A datagram channel may be
  45  * connected, by invoking its {@link #connect connect} method, in order to
  46  * avoid the overhead of the security checks are otherwise performed as part of
  47  * every send and receive operation.  A datagram channel must be connected in
  48  * order to use the {@link #read(java.nio.ByteBuffer) read} and {@link
  49  * #write(java.nio.ByteBuffer) write} methods, since those methods do not
  50  * accept or return socket addresses.
  51  *
  52  * <p> Once connected, a datagram channel remains connected until it is
  53  * disconnected or closed.  Whether or not a datagram channel is connected may
  54  * be determined by invoking its {@link #isConnected isConnected} method.
  55  *
  56  * <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
  57  * setOption} method. A datagram channel to an Internet Protocol socket supports
  58  * the following options:
  59  * <blockquote>
  60  * <table border summary="Socket options">


  61  *   <tr>
  62  *     <th>Option Name</th>
  63  *     <th>Description</th>
  64  *   </tr>


  65  *   <tr>
  66  *     <td> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </td>
  67  *     <td> The size of the socket send buffer </td>
  68  *   </tr>
  69  *   <tr>
  70  *     <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
  71  *     <td> The size of the socket receive buffer </td>
  72  *   </tr>
  73  *   <tr>
  74  *     <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
  75  *     <td> Re-use address </td>
  76  *   </tr>
  77  *   <tr>
  78  *     <td> {@link java.net.StandardSocketOptions#SO_BROADCAST SO_BROADCAST} </td>
  79  *     <td> Allow transmission of broadcast datagrams </td>
  80  *   </tr>
  81  *   <tr>
  82  *     <td> {@link java.net.StandardSocketOptions#IP_TOS IP_TOS} </td>
  83  *     <td> The Type of Service (ToS) octet in the Internet Protocol (IP) header </td>
  84  *   </tr>
  85  *   <tr>
  86  *     <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_IF IP_MULTICAST_IF} </td>
  87  *     <td> The network interface for Internet Protocol (IP) multicast datagrams </td>
  88  *   </tr>
  89  *   <tr>
  90  *     <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_TTL
  91  *       IP_MULTICAST_TTL} </td>
  92  *     <td> The <em>time-to-live</em> for Internet Protocol (IP) multicast
  93  *       datagrams </td>
  94  *   </tr>
  95  *   <tr>
  96  *     <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP
  97  *       IP_MULTICAST_LOOP} </td>
  98  *     <td> Loopback for Internet Protocol (IP) multicast datagrams </td>
  99  *   </tr>

 100  * </table>
 101  * </blockquote>
 102  * Additional (implementation specific) options may also be supported.
 103  *
 104  * <p> Datagram channels are safe for use by multiple concurrent threads.  They
 105  * support concurrent reading and writing, though at most one thread may be
 106  * reading and at most one thread may be writing at any given time.  </p>
 107  *
 108  * @author Mark Reinhold
 109  * @author JSR-51 Expert Group
 110  * @since 1.4
 111  */
 112 
 113 public abstract class DatagramChannel
 114     extends AbstractSelectableChannel
 115     implements ByteChannel, ScatteringByteChannel, GatheringByteChannel, MulticastChannel
 116 {
 117 
 118     /**
 119      * Initializes a new instance of this class.




  40  * <p> A datagram channel is created by invoking one of the {@link #open open} methods
  41  * of this class. It is not possible to create a channel for an arbitrary,
  42  * pre-existing datagram socket. A newly-created datagram channel is open but not
  43  * connected. A datagram channel need not be connected in order for the {@link #send
  44  * send} and {@link #receive receive} methods to be used.  A datagram channel may be
  45  * connected, by invoking its {@link #connect connect} method, in order to
  46  * avoid the overhead of the security checks are otherwise performed as part of
  47  * every send and receive operation.  A datagram channel must be connected in
  48  * order to use the {@link #read(java.nio.ByteBuffer) read} and {@link
  49  * #write(java.nio.ByteBuffer) write} methods, since those methods do not
  50  * accept or return socket addresses.
  51  *
  52  * <p> Once connected, a datagram channel remains connected until it is
  53  * disconnected or closed.  Whether or not a datagram channel is connected may
  54  * be determined by invoking its {@link #isConnected isConnected} method.
  55  *
  56  * <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
  57  * setOption} method. A datagram channel to an Internet Protocol socket supports
  58  * the following options:
  59  * <blockquote>
  60  * <table class="striped">
  61  * <caption style="display:none">Socket options</caption>
  62  * <thead>
  63  *   <tr>
  64  *     <th>Option Name</th>
  65  *     <th>Description</th>
  66  *   </tr>
  67  * </thead>
  68  * <tbody>
  69  *   <tr>
  70  *     <td> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </td>
  71  *     <td> The size of the socket send buffer </td>
  72  *   </tr>
  73  *   <tr>
  74  *     <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
  75  *     <td> The size of the socket receive buffer </td>
  76  *   </tr>
  77  *   <tr>
  78  *     <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
  79  *     <td> Re-use address </td>
  80  *   </tr>
  81  *   <tr>
  82  *     <td> {@link java.net.StandardSocketOptions#SO_BROADCAST SO_BROADCAST} </td>
  83  *     <td> Allow transmission of broadcast datagrams </td>
  84  *   </tr>
  85  *   <tr>
  86  *     <td> {@link java.net.StandardSocketOptions#IP_TOS IP_TOS} </td>
  87  *     <td> The Type of Service (ToS) octet in the Internet Protocol (IP) header </td>
  88  *   </tr>
  89  *   <tr>
  90  *     <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_IF IP_MULTICAST_IF} </td>
  91  *     <td> The network interface for Internet Protocol (IP) multicast datagrams </td>
  92  *   </tr>
  93  *   <tr>
  94  *     <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_TTL
  95  *       IP_MULTICAST_TTL} </td>
  96  *     <td> The <em>time-to-live</em> for Internet Protocol (IP) multicast
  97  *       datagrams </td>
  98  *   </tr>
  99  *   <tr>
 100  *     <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP
 101  *       IP_MULTICAST_LOOP} </td>
 102  *     <td> Loopback for Internet Protocol (IP) multicast datagrams </td>
 103  *   </tr>
 104  * </tbody>
 105  * </table>
 106  * </blockquote>
 107  * Additional (implementation specific) options may also be supported.
 108  *
 109  * <p> Datagram channels are safe for use by multiple concurrent threads.  They
 110  * support concurrent reading and writing, though at most one thread may be
 111  * reading and at most one thread may be writing at any given time.  </p>
 112  *
 113  * @author Mark Reinhold
 114  * @author JSR-51 Expert Group
 115  * @since 1.4
 116  */
 117 
 118 public abstract class DatagramChannel
 119     extends AbstractSelectableChannel
 120     implements ByteChannel, ScatteringByteChannel, GatheringByteChannel, MulticastChannel
 121 {
 122 
 123     /**
 124      * Initializes a new instance of this class.


< prev index next >