java.nio.channels
public
abstract
class
java.nio.channels.ServerSocketChannel
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.
Summary
Protected Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Protected Constructors
protected
ServerSocketChannel(SelectorProvider selectorProvider)
Construct a new instance for ServerSocketChannel
Parameters
selectorProvider
| An instance of SelectorProvider
|
Public Methods
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.
Returns
- The accepted SocketChannel instance, or null as the channel is
non-blocking and no connections available.
Create an open and unbound server-socket channel.
This channel is got by calling openServerSocketChannel
method of the default SelectorProvider
instance.
Returns
- The new created channel which is open but unbound.
public
abstract
ServerSocket
socket()
Return the related server-socket of this channel.
All public methods declared in returned object should be declared in
ServerSocket
.
Returns
- The related ServerSocket instance.
public
final
int
validOps()
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
.
Returns
- Valid operations in bit-set.