org.xsocket.connection
Interface 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;
}
}
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.
RuntimeException - if an runtime exception occurs. Throwing this exception causes that the underlying connection will be closed.