| |
|
| java.lang.Object java.nio.channels.spi.AbstractInterruptibleChannel java.nio.channels.SelectableChannel java.nio.channels.spi.AbstractSelectableChannel java.nio.channels.ServerSocketChannel
ServerSocketChannel | abstract public class ServerSocketChannel extends AbstractSelectableChannel (Code) | | A selectable channel for stream-oriented listening sockets.
Server-socket channels are not a complete abstraction of listening
network sockets. Binding and the manipulation of socket options must be
done through an associated
java.net.ServerSocket object obtained by
invoking the
ServerSocketChannel.socket() socket method. It is not possible to create
a channel for an arbitrary, pre-existing server socket, nor is it possible
to specify the
java.net.SocketImpl object to be used by a server
socket associated with a server-socket channel.
A server-socket channel is created by invoking the
ServerSocketChannel.open() open method of this class. A newly-created server-socket channel is open but not
yet bound. An attempt to invoke the
ServerSocketChannel.accept() accept method of an
unbound server-socket channel will cause a
NotYetBoundException to
be thrown. A server-socket channel can be bound by invoking one of the
java.net.ServerSocket.bind(java.net.SocketAddressint) bind methods
of an associated server socket.
Server-socket channels are safe for use by multiple concurrent threads.
author: Mark Reinhold author: JSR-51 Expert Group version: 1.31, 07/05/05 since: 1.4 |
ServerSocketChannel | protected ServerSocketChannel(SelectorProvider provider)(Code) | | Initializes a new instance of this class.
|
accept | abstract public SocketChannel accept() throws IOException(Code) | | Accepts a connection made to this channel's socket.
If this channel is in non-blocking mode then this method will
immediately return null if there are no pending connections.
Otherwise it will block indefinitely until a new connection is available
or an I/O error occurs.
The socket channel returned by this method, if any, will be in
blocking mode regardless of the blocking mode of this channel.
This method performs exactly the same security checks as the
java.net.ServerSocket.accept accept method of the
java.net.ServerSocket class. That is, if a security manager has been
installed then for each new connection this method verifies that the
address and port number of the connection's remote endpoint are
permitted by the security manager's
java.lang.SecurityManager.checkAccept checkAccept method.
The socket channel for the new connection,or null if this channel is in non-blocking modeand no connection is available to be accepted throws: ClosedChannelException - If this channel is closed throws: AsynchronousCloseException - If another thread closes this channelwhile the accept operation is in progress throws: ClosedByInterruptException - If another thread interrupts the current threadwhile the accept operation is in progress, therebyclosing the channel and setting the current thread'sinterrupt status throws: NotYetBoundException - If this channel's socket has not yet been bound throws: SecurityException - If a security manager has been installedand it does not permit access to the remote endpointof the new connection throws: IOException - If some other I/O error occurs |
socket | abstract public ServerSocket socket()(Code) | | Retrieves a server socket associated with this channel.
The returned object will not declare any public methods that are not
declared in the
java.net.ServerSocket class.
A server socket associated with this channel |
validOps | final public int validOps()(Code) | | Returns an operation set identifying this channel's supported
operations.
Server-socket channels only support the accepting of new
connections, so this method returns
SelectionKey.OP_ACCEPT .
The valid-operation set |
|
|
|