ServerSocketChannel

public abstract class ServerSocketChannel extends AbstractSelectableChannel
implements NetworkChannel

A selectable channel for stream-oriented listening sockets.

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:

Option Name Description
SO_RCVBUF The size of the socket receive buffer
SO_REUSEADDR Re-use address
Additional (implementation specific) options may also be supported.

Server-socket channels are safe for use by multiple concurrent threads.

Protected Constructor Summary

ServerSocketChannel(SelectorProvider provider)
Initializes a new instance of this class.

Public Method Summary

abstract SocketChannel
accept()
Accepts a connection made to this channel's socket.
abstract ServerSocketChannel
bind(SocketAddress local, int backlog)
Binds the channel's socket to a local address and configures the socket to listen for connections.
final ServerSocketChannel
bind(SocketAddress local)
Binds the channel's socket to a local address and configures the socket to listen for connections.
static ServerSocketChannel
open()
Opens a server-socket channel.
abstract <T> ServerSocketChannel
setOption(SocketOption<T> name, T value)
Sets the value of a socket option.
abstract ServerSocket
socket()
Retrieves a server socket associated with this channel.
final int
validOps()
Returns an operation set identifying this channel's supported operations.

Inherited Method Summary