| |
|
| java.nio.channels.SelectableChannel java.nio.channels.spi.AbstractSelectableChannel java.nio.channels.ServerSocketChannel
ServerSocketChannel | abstract public class ServerSocketChannel extends AbstractSelectableChannel (Code) | | 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.
|
Method Summary | |
abstract public SocketChannel | accept() Accepts a connection to this socket.
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. | public static ServerSocketChannel | open() Create an open and unbound server-socket channel. | abstract public ServerSocket | socket() Return the related server-socket of this channel. | final public int | validOps() Get the valid operations of this channel. |
ServerSocketChannel | protected ServerSocketChannel(SelectorProvider selectorProvider)(Code) | | Construct a new instance for ServerSocketChannel
Parameters: selectorProvider - An instance of SelectorProvider |
accept | abstract public SocketChannel accept() throws IOException(Code) | | Accepts a connection to this socket.
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.
The accepted SocketChannel instance, or null as the channel isnon-blocking and no connections available. throws: ClosedChannelException - If the channel is already closed. throws: AsynchronousCloseException - If the channel is closed by another thread while this methodis in operation. throws: ClosedByInterruptException - If another thread interrupts the calling thread while theoperation is in progress. The calling thread will have theinterrupt state set, and the channel will be closed. throws: NotYetBoundException - If the socket has not yet been bound. throws: SecurityException - If there is a security manager, and the new connection is notpermitted to access. throws: IOException - Some other IO error occurred. |
open | public static ServerSocketChannel open() throws IOException(Code) | | Create an open and unbound server-socket channel.
This channel is got by calling openServerSocketChannel
method of the default SelectorProvider instance.
The new created channel which is open but unbound. throws: IOException - If some IO problem occurs. |
socket | abstract public ServerSocket socket()(Code) | | Return the related server-socket of this channel. All public methods
declared in returned object should be declared in
ServerSocket .
The related ServerSocket instance. |
validOps | final public int validOps()(Code) | | Get the valid operations of this channel. Server-socket channels support
accepting operation.Currently the only supported operation is OP_ACCEPT.
It always returns SelectionKey.OP_ACCEPT .
See Also: java.nio.channels.SelectableChannel.validOps Valid operations in bit-set. |
|
|
|