A ServerSocketChannel is a partly abstracted stream-oriented listening socket
which is selectable. Binding and manipulation of socket options can only be done
through the associated ServerSocket object, returned by calling
socket method. ServerSocketChannels can not be constructed for a pre-existing
server socket, nor can it be assigned a SocketImpl.
A Server-Socket channel is open but not bound when created by
open method. (Calling accept before bound will cause a
NotYetBoundException). It can be bound by calling the bind method
of a related ServerSocket instance.
| ServerSocketChannel(SelectorProvider selectorProvider) | |||||
| Construct a new instance for ServerSocketChannel | |||||
| abstract | SocketChannel | accept() | |||
| Accepts a connection to this socket. | |||||
| static | ServerSocketChannel | open() | |||
| Create an open and unbound server-socket channel. | |||||
| abstract | ServerSocket | socket() | |||
| Return the related server-socket of this channel. | |||||
| final | int | validOps() | |||
| Get the valid operations of this channel. | |||||
Methods inherited
from class
java.nio.channels.spi.AbstractSelectableChannel
Methods inherited
from class
java.nio.channels.SelectableChannel
Methods inherited
from class
java.nio.channels.spi.AbstractInterruptibleChannel
Methods inherited
from class
java.lang.Object
Methods inherited
from interface
java.io.Closeable
Methods inherited
from interface
java.nio.channels.InterruptibleChannel
Methods inherited
from interface
java.nio.channels.Channel
| selectorProvider | An instance of SelectorProvider |
|---|
It returns null when the channel is non-blocking and no connections available, otherwise it blocks indefinitely until a new connection is available or an I/O error occurs. The returned channel will be in blocking mode any way.
This method just execute the same security checks as the accept method of
the ServerSocket class.
| ClosedChannelException | If the channel is already closed. |
|---|---|
| AsynchronousCloseException | If the channel is closed by another thread while this method is in operation. |
| ClosedByInterruptException | If another thread interrupts the calling thread while the operation is in progress. The calling thread will have the interrupt state set, and the channel will be closed. |
| NotYetBoundException | If the socket has not yet been bound. |
| SecurityException | If there is a security manager, and the new connection is not permitted to access. |
| IOException | Some other IO error occurred. |
This channel is got by calling openServerSocketChannel
method of the default SelectorProvider instance.
| IOException | If some IO problem occurs. |
|---|
ServerSocket.
SelectionKey.OP_ACCEPT.