public class HandshakeableSocketAcceptor extends TimeableConnection
This acceptor works similar to SocketAcceptor except for the addition of adding handshaking capability.
SocketAcceptor| Modifier and Type | Field and Description |
|---|---|
protected java.net.ServerSocket |
socket |
listenerList| Constructor and Description |
|---|
HandshakeableSocketAcceptor() |
HandshakeableSocketAcceptor(ConnectionModel model) |
HandshakeableSocketAcceptor(ConnectionModel model,
int backlog) |
| Modifier and Type | Method and Description |
|---|---|
void |
aaccept(HandshakeableSocketHandler socketHandler)
The asynchronous version of the accept method.
|
void |
accept(HandshakeableSocketHandler socketHandler)
Accepts a connection synchronously and hands it over to the handler for processing.
|
void |
close()
Closes the server socket and unbind from the port.
|
ConnectionModel |
getConnectionModel() |
void |
open(int backlog) |
void |
setConnectionModel(ConnectionModel connectionModel)
use a new connection model.
|
void |
setConnectionModel(ConnectionModel connectionModel,
int backlog)
sets the connection model plus the backlog for the port that the listener
should bind to and listen on.
|
fireConnectionClosed, fireConnectionEstablishedaddConnectionListener, fireConnectionStarting, fireConnectionStartingWithoutVeto, removeConnectionListenerpublic HandshakeableSocketAcceptor()
public HandshakeableSocketAcceptor(ConnectionModel model) throws java.io.IOException
java.io.IOExceptionpublic HandshakeableSocketAcceptor(ConnectionModel model, int backlog) throws java.io.IOException
java.io.IOExceptionpublic void open(int backlog)
throws java.io.IOException
java.io.IOExceptionpublic void accept(HandshakeableSocketHandler socketHandler)
Accepts a connection synchronously and hands it over to the handler for processing. The caller of this method will wait until data processing is finished before regaining control. This is meant for occassions such as HTTP requests where retrieval of data occurs once and data is returned for further processing.
Notice that the server socket is NOT closed after handler returns. The connection should be closed explicitly by the application or inside the handler.
public void aaccept(HandshakeableSocketHandler socketHandler)
The asynchronous version of the accept method. The connection is passed to a thread for execution. The server socket is not automatically closed at the end. You must explicitly close the server socket when you're done. Failure to do so will result in a port that's binded until the end of the application.
public void close()
public ConnectionModel getConnectionModel()
public void setConnectionModel(ConnectionModel connectionModel) throws java.io.IOException
use a new connection model. The current server socket will be closed and then a new server socket will be created. Once a connection model is passed in through the constructor, it's not usually changed. However, the Acceptor can be reused in this way if the situation requires it.
java.io.IOExceptionpublic void setConnectionModel(ConnectionModel connectionModel, int backlog) throws java.io.IOException
java.io.IOExceptionCopyright © 2001-2005 Echomine. All Rights Reserved.