A server-socket channel is created by invoking the open
method of this class. It is not possible to create a channel for an arbitrary,
pre-existing ServerSocket. A newly-created server-socket channel is
open but not yet bound. An attempt to invoke the 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
bind methods defined by this class.

Socket options are configured using the setOption method. Server-socket channels support the following options:

bind

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 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 address to bind the socket, or null to bind to an
automatically assigned socket address

accept

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 accept method of the 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 checkAccept method.

Returns:

The socket channel for the new connection,
or null if this channel is in non-blocking mode
and no connection is available to be accepted

getLocalAddress

Where the channel is bound to an Internet Protocol
socket address then the return value from this method is of type InetSocketAddress.

If there is a security manager set, its checkConnect method is
called with the local address and -1 as its arguments to see
if the operation is allowed. If the operation is not allowed,
a SocketAddress representing the
loopback address and the
local port of the channel's socket is returned.