org.szegedi.nioserver
Interface ProtocolHandler

All Known Implementing Classes:
AbstractPipedProtocolHandler

public interface ProtocolHandler

Interface for objects that service read and write operations on a socket for a single connection.

Version:
$Id: ProtocolHandler.java,v 1.3 2002/02/11 08:18:30 szegedia Exp $
Author:
Attila Szegedi, szegedia at freemail dot hu

Method Summary
 boolean tryToRead()
          Called when the socket channel is reported to be ready for reading.
 boolean tryToWrite()
          Called when the socket channel is reported to be ready for writing.
 int validOps()
          Returns a bit mask of SelectionKey.OP_XXX values that represent the operations this handler supports.
 

Method Detail

tryToRead

public boolean tryToRead()
                  throws java.io.IOException
Called when the socket channel is reported to be ready for reading.

Returns:
true if the selection key associated with the connection on the read thread should be cancelled, false otherwise.
java.io.IOException

tryToWrite

public boolean tryToWrite()
                   throws java.io.IOException
Called when the socket channel is reported to be ready for writing.

Returns:
true if the selection key associated with the connection on the write thread should be cancelled, false otherwise.
java.io.IOException

validOps

public int validOps()
Returns a bit mask of SelectionKey.OP_XXX values that represent the operations this handler supports. Most typically, this will be SelectionKey.OP_READ | SelectionKey.OP_WRITE. However, some protocols can be read-only or write-only, in which case only the appropriate value should be returned.