org.xsocket.connection
Interface IConnectHandler

Package class diagram package IConnectHandler
All Superinterfaces:
IHandler
All Known Implementing Classes:
HandlerChain

public interface IConnectHandler
extends IHandler

Handles new incoming connections.

E.g.

 public final class BlackIpHandler implements IConnectHandler {
   ...
   
   public boolean onConnect(INonBlockingConnection connection) throws IOException {
      connection.write("220 my smtp server" + LINE_DELIMITER);
      return true;
   }
 } 
 

Author:
grro@xsocket.org

Field Summary
 
Fields inherited from interface org.xsocket.connection.IHandler
DEFAULT_EXECUTION_MODE
 
Method Summary
 boolean onConnect(INonBlockingConnection connection)
          handles a new incoming connection
 

Method Detail

onConnect

boolean onConnect(INonBlockingConnection connection)
                  throws IOException,
                         BufferUnderflowException,
                         MaxReadSizeExceededException
handles a new incoming connection

Returns:
true for positive result of handling, false for negative result of handling
Throws:
IOException - if some other I/O error occurs. Throwing this exception causes that the underlying connection will be closed.
BufferUnderflowException - if more incoming data is required to process (e.g. delimiter hasn't yet received -> readByDelimiter methods or size of the available, received data is smaller than the required size -> readByLength). The BufferUnderflowException will be swallowed by the framework
MaxReadSizeExceededException - if the max read size has been reached (e.g. by calling method IDataSource.readStringByDelimiter(String, int)). Throwing this exception causes that the underlying connection will be closed.


Copyright 2008 xSocket.org