com.echomine.net
Class HandshakeablePerpetualSocketAcceptor

java.lang.Object
  extended by com.echomine.net.Connection
      extended by com.echomine.net.TimeableConnection
          extended by com.echomine.net.HandshakeableSocketAcceptor
              extended by com.echomine.net.HandshakeablePerpetualSocketAcceptor

public class HandshakeablePerpetualSocketAcceptor
extends HandshakeableSocketAcceptor

Accepts connections indefinitely. Once a connection is accepted, it is immediately handled in a spawned thread. The acceptor will go back to receiving more connections.

The socket acceptor work similar to PerpetualSocketAcceptor

See Also:
PerpetualSocketAcceptor

Field Summary
 
Fields inherited from class com.echomine.net.HandshakeableSocketAcceptor
socket
 
Fields inherited from class com.echomine.net.Connection
listenerList
 
Constructor Summary
HandshakeablePerpetualSocketAcceptor()
           
HandshakeablePerpetualSocketAcceptor(ConnectionModel model)
           
HandshakeablePerpetualSocketAcceptor(ConnectionModel model, int backlog)
           
 
Method Summary
 void aaccept(HandshakeableSocketHandler socketHandler)
          Accepts a connection,hands it over to the handler for processing, and immediately goes back to accepting more connections.
 void accept(HandshakeableSocketHandler socketHandler)
          Accepts a connection and hands it over to the handler for processing one at a time.
 void close()
          Closes the server socket, unbind from the port, and shuts down the perpetual loops.
 
Methods inherited from class com.echomine.net.HandshakeableSocketAcceptor
getConnectionModel, open, setConnectionModel, setConnectionModel
 
Methods inherited from class com.echomine.net.TimeableConnection
fireConnectionClosed, fireConnectionEstablished
 
Methods inherited from class com.echomine.net.Connection
addConnectionListener, fireConnectionStarting, fireConnectionStartingWithoutVeto, removeConnectionListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandshakeablePerpetualSocketAcceptor

public HandshakeablePerpetualSocketAcceptor()

HandshakeablePerpetualSocketAcceptor

public HandshakeablePerpetualSocketAcceptor(ConnectionModel model)
                                     throws java.io.IOException
Throws:
java.io.IOException

HandshakeablePerpetualSocketAcceptor

public HandshakeablePerpetualSocketAcceptor(ConnectionModel model,
                                            int backlog)
                                     throws java.io.IOException
Throws:
java.io.IOException
Method Detail

accept

public void accept(HandshakeableSocketHandler socketHandler)

Accepts a connection and hands it over to the handler for processing one at a time.

To stop the daemon from accepting more connections, just call the close method.

The method will return immediately and run the daemon in a background thread.

Overrides:
accept in class HandshakeableSocketAcceptor

aaccept

public void aaccept(HandshakeableSocketHandler socketHandler)

Accepts a connection,hands it over to the handler for processing, and immediately goes back to accepting more connections. This differs from the regular accept method in that it does not process connections one at a time.

The async accept is a little more intricate than the sync accept since it can't just use SocketAcceptor.aaccept().

The method returns immediately and runs the daemon in a background thread.

Overrides:
aaccept in class HandshakeableSocketAcceptor

close

public void close()

Closes the server socket, unbind from the port, and shuts down the perpetual loops. The close does NOT close all the currently accepted (and processing) handlers. It only close the server socket so that additional connections are refused. It is up to you to keep track of the handlers and also close them if you want all connections to be shutdown.

Overrides:
close in class HandshakeableSocketAcceptor


Copyright © 2001-2005 Echomine. All Rights Reserved.