Class FiberServerSocketChannel

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel, java.nio.channels.NetworkChannel

    public abstract class FiberServerSocketChannel
    extends java.lang.Object
    implements java.nio.channels.NetworkChannel
    A fiber-blocking version of ServerSocketChannel.
    • Constructor Detail

      • FiberServerSocketChannel

        public FiberServerSocketChannel()
    • Method Detail

      • open

        public static FiberServerSocketChannel open​(ChannelGroup group)
                                             throws java.io.IOException,
                                                    SuspendExecution
        Opens an server-socket channel.

        If the group parameter is null then the resulting channel is created by the system-wide default provider, and bound to the default group.

        Parameters:
        group - The group to which the newly constructed channel should be bound, or null for the default group
        Returns:
        A new server socket channel
        Throws:
        java.nio.channels.ShutdownChannelGroupException - If the channel group is shutdown
        java.io.IOException - If an I/O error occurs
        SuspendExecution
      • accept

        public abstract FiberSocketChannel accept()
                                           throws java.io.IOException,
                                                  SuspendExecution
        Accepts a connection.

        This method accepts a connection made to this channel's socket. The returned result is the FiberSocketChannel to the new connection.

        When a new connection is accepted then the resulting FiberSocketChannel will be bound to the same ChannelGroup as this channel. If the group is shutdown and a connection is accepted, then the connection is closed, and the method throws an IOException with cause ShutdownChannelGroupException.

        If a security manager has been installed then it verifies that the address and port number of the connection's remote endpoint are permitted by the security manager's checkAccept method. The permission check is performed with privileges that are restricted by the calling context of this method. If the permission check fails then the connection is closed and the operation completes with a SecurityException.

        Returns:
        the FiberSocketChannel to the new connection.
        Throws:
        java.nio.channels.AcceptPendingException - If an accept operation is already in progress on this channel
        java.nio.channels.NotYetBoundException - If this channel's socket has not yet been bound
        java.nio.channels.ShutdownChannelGroupException - If the channel group has terminated
        java.io.IOException
        SuspendExecution
      • isOpen

        public abstract boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • close

        public abstract void close()
                            throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • bind

        public abstract FiberServerSocketChannel bind​(java.net.SocketAddress local)
                                               throws java.io.IOException
        Binds the channel's socket to a local address and configures the socket to listen for connections.

        An invocation of this method is equivalent to the following:

         bind(local, 0);
         
        Specified by:
        bind in interface java.nio.channels.NetworkChannel
        Parameters:
        local - The local address to bind the socket, or null to bind to an automatically assigned socket address
        Returns:
        This channel
        Throws:
        java.nio.channels.AlreadyBoundException
        java.nio.channels.UnsupportedAddressTypeException
        java.lang.SecurityException
        java.nio.channels.ClosedChannelException
        java.io.IOException
      • bind

        public abstract FiberServerSocketChannel bind​(java.net.SocketAddress local,
                                                      int backlog)
                                               throws java.io.IOException
        Binds the channel's socket to a local address and configures the socket to listen for connections.

        This method is used to establish an association between the socket and a local address. Once an association is established then the socket remains bound until the associated channel is closed.

        The backlog parameter is the maximum number of pending connections on the socket. Its exact semantics are implementation specific. In particular, an implementation may impose a maximum length or may choose to ignore the parameter altogther. If the backlog parameter has the value 0, or a negative value, then an implementation specific default is used.

        Parameters:
        local - The local address to bind the socket, or null to bind to an automatically assigned socket address
        backlog - The maximum number of pending connections
        Returns:
        This channel
        Throws:
        java.nio.channels.AlreadyBoundException - If the socket is already bound
        java.nio.channels.UnsupportedAddressTypeException - If the type of the given address is not supported
        java.lang.SecurityException - If a security manager has been installed and its checkListen method denies the operation
        java.nio.channels.ClosedChannelException - If the channel is closed
        java.io.IOException - If some other I/O error occurs
      • setOption

        public abstract <T> FiberServerSocketChannel setOption​(java.net.SocketOption<T> name,
                                                               T value)
                                                        throws java.io.IOException
        Specified by:
        setOption in interface java.nio.channels.NetworkChannel
        Throws:
        java.lang.IllegalArgumentException
        java.nio.channels.ClosedChannelException
        java.io.IOException
      • getLocalAddress

        public abstract java.net.SocketAddress getLocalAddress()
                                                        throws java.io.IOException
        Specified by:
        getLocalAddress in interface java.nio.channels.NetworkChannel
        Throws:
        java.io.IOException
      • getOption

        public abstract <T> T getOption​(java.net.SocketOption<T> name)
                                 throws java.io.IOException
        Specified by:
        getOption in interface java.nio.channels.NetworkChannel
        Throws:
        java.io.IOException
      • supportedOptions

        public abstract java.util.Set<java.net.SocketOption<?>> supportedOptions()
        Specified by:
        supportedOptions in interface java.nio.channels.NetworkChannel
      • provider

        public abstract java.lang.Object provider()
        Returns the IO provider that created this channel. The type of the returned value is implementation dependent, and may be null.