< prev index next >

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

Print this page




  29 import java.net.ServerSocket;
  30 import java.net.SocketOption;
  31 import java.net.SocketAddress;
  32 import java.nio.channels.spi.AbstractSelectableChannel;
  33 import java.nio.channels.spi.SelectorProvider;
  34 
  35 /**
  36  * A selectable channel for stream-oriented listening sockets.
  37  *
  38  * <p> A server-socket channel is created by invoking the {@link #open() open}
  39  * method of this class.  It is not possible to create a channel for an arbitrary,
  40  * pre-existing {@link ServerSocket}. A newly-created server-socket channel is
  41  * open but not yet bound.  An attempt to invoke the {@link #accept() accept}
  42  * method of an unbound server-socket channel will cause a {@link NotYetBoundException}
  43  * to be thrown. A server-socket channel can be bound by invoking one of the
  44  * {@link #bind(java.net.SocketAddress,int) bind} methods defined by this class.
  45  *
  46  * <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
  47  * setOption} method. Server-socket channels support the following options:
  48  * <blockquote>
  49  * <table border summary="Socket options">


  50  *   <tr>
  51  *     <th>Option Name</th>
  52  *     <th>Description</th>
  53  *   </tr>


  54  *   <tr>
  55  *     <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
  56  *     <td> The size of the socket receive buffer </td>
  57  *   </tr>
  58  *   <tr>
  59  *     <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
  60  *     <td> Re-use address </td>
  61  *   </tr>

  62  * </table>
  63  * </blockquote>
  64  * Additional (implementation specific) options may also be supported.
  65  *
  66  * <p> Server-socket channels are safe for use by multiple concurrent threads.
  67  * </p>
  68  *
  69  * @author Mark Reinhold
  70  * @author JSR-51 Expert Group
  71  * @since 1.4
  72  */
  73 
  74 public abstract class ServerSocketChannel
  75     extends AbstractSelectableChannel
  76     implements NetworkChannel
  77 {
  78 
  79     /**
  80      * Initializes a new instance of this class.
  81      *




  29 import java.net.ServerSocket;
  30 import java.net.SocketOption;
  31 import java.net.SocketAddress;
  32 import java.nio.channels.spi.AbstractSelectableChannel;
  33 import java.nio.channels.spi.SelectorProvider;
  34 
  35 /**
  36  * A selectable channel for stream-oriented listening sockets.
  37  *
  38  * <p> A server-socket channel is created by invoking the {@link #open() open}
  39  * method of this class.  It is not possible to create a channel for an arbitrary,
  40  * pre-existing {@link ServerSocket}. A newly-created server-socket channel is
  41  * open but not yet bound.  An attempt to invoke the {@link #accept() accept}
  42  * method of an unbound server-socket channel will cause a {@link NotYetBoundException}
  43  * to be thrown. A server-socket channel can be bound by invoking one of the
  44  * {@link #bind(java.net.SocketAddress,int) bind} methods defined by this class.
  45  *
  46  * <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
  47  * setOption} method. Server-socket channels support the following options:
  48  * <blockquote>
  49  * <table class="striped">
  50  * <caption style="display:none">Socket options</caption>
  51  * <thead>
  52  *   <tr>
  53  *     <th>Option Name</th>
  54  *     <th>Description</th>
  55  *   </tr>
  56  * </thead>
  57  * <tbody>
  58  *   <tr>
  59  *     <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
  60  *     <td> The size of the socket receive buffer </td>
  61  *   </tr>
  62  *   <tr>
  63  *     <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
  64  *     <td> Re-use address </td>
  65  *   </tr>
  66  * </tbody>
  67  * </table>
  68  * </blockquote>
  69  * Additional (implementation specific) options may also be supported.
  70  *
  71  * <p> Server-socket channels are safe for use by multiple concurrent threads.
  72  * </p>
  73  *
  74  * @author Mark Reinhold
  75  * @author JSR-51 Expert Group
  76  * @since 1.4
  77  */
  78 
  79 public abstract class ServerSocketChannel
  80     extends AbstractSelectableChannel
  81     implements NetworkChannel
  82 {
  83 
  84     /**
  85      * Initializes a new instance of this class.
  86      *


< prev index next >