FileDocCategorySizeDatePackage
ServerSocketChannel.javaAPI DocAndroid 1.5 API4976Wed May 06 22:41:04 BST 2009java.nio.channels

ServerSocketChannel

public abstract class ServerSocketChannel extends AbstractSelectableChannel
A {@code ServerSocketChannel} is a partial abstraction of a selectable, stream-oriented listening socket. Binding and manipulation of socket options can only be done through the associated {@link ServerSocket} object, returned by calling {@code socket()}. ServerSocketChannels can not be constructed for an already existing server-socket, nor can a {@link java.net.SocketImpl} be assigned.

A server-socket channel is open but not bound when created by the {@code open()} method. Calling {@code accept} before bound will cause a {@link NotYetBoundException}. It can be bound by calling the bind method of a related {@code ServerSocket} instance.

since
Android 1.0

Fields Summary
Constructors Summary
protected ServerSocketChannel(SelectorProvider selectorProvider)
Constructs a new {@link ServerSocketChannel}.

param
selectorProvider an instance of SelectorProvider.
since
Android 1.0

        super(selectorProvider);
    
Methods Summary
public abstract java.nio.channels.SocketChannelaccept()
Accepts a connection to this server-socket channel.

This method returns {@code null} when this channel is non-blocking and no connection is available, otherwise it blocks until a new connection is available or an I/O error occurs. The socket channel returned by this method will always be in blocking mode.

This method just executes the same security checks as the {@code accept()} method of the {@link ServerSocket} class.

return
the accepted {@code SocketChannel} instance, or {@code null} if the channel is non-blocking and no connection is available.
throws
AsynchronousCloseException if this channel is closed by another thread while this method is in operation.
throws
ClosedByInterruptException if another thread interrupts the calling thread while this operation is in progress. The interrupt state of the calling thread is set and the channel is closed.
throws
ClosedChannelException if this channel is closed.
throws
IOException if another I/O error occurs.
throws
NotYetBoundException if the socket has not yet been bound.
throws
SecurityException if there is a security manager and it does not permit to access the new connection.
since
Android 1.0

public static java.nio.channels.ServerSocketChannelopen()
Creates an open and unbound server-socket channel.

This channel is created by calling {@code openServerSocketChannel} method of the default {@code SelectorProvider} instance.

return
the new channel which is open but unbound.
throws
IOException if an I/O error occurs.
since
Android 1.0

        return SelectorProvider.provider().openServerSocketChannel();
    
public abstract java.net.ServerSocketsocket()
Return the server-socket assigned this channel, which does not declare any public methods that are not declared in {@code ServerSocket}.

return
the server-socket assigned to this channel.
since
Android 1.0

public final intvalidOps()
Gets the valid operations of this channel. Server-socket channels support accepting operation, so this method returns {@code SelectionKey.OP_ACCEPT}.

see
java.nio.channels.SelectableChannel#validOps()
return
the operations supported by this channel.
since
Android 1.0

        return SelectionKey.OP_ACCEPT;