< prev index next >

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

Print this page




  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 {




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


< prev index next >