net.sf.cindy
Interface SessionAcceptor

All Known Implementing Classes:
AbstractSessionAcceptor, BlockingSessionAcceptor, NonBlockingSessionAcceptor

public interface SessionAcceptor

Session acceptor, accept incoming sessions.

Version:
$id$
Author:
Roger Chen

Method Summary
 void close()
          Close acceptor.
 int getAcceptedCount()
          Get accepted session count.
 SessionAcceptorHandler getAcceptorHandler()
          Get the acceptor handler associated with this acceptor.
 int getBacklog()
          Get the maximum queue length for incoming connection.
 java.net.SocketAddress getListenAddress()
          Get the listen address which the accpetor bind with.
 int getListenPort()
          Get the listen port which the acceptor bind with.
 SessionType getSessionType()
          Get the session type of the session accepted by the acceptor.
 boolean isReuseAddress()
          Tests if SO_REUSEADDR is enabled.
 boolean isStarted()
          Acceptor is started.
 void setAcceptorHandler(SessionAcceptorHandler handler)
          Set the acceptor handler associated with this acceptor.
 void setBacklog(int backlog)
          Set the maximum queue length for incoming connection.
 void setListenAddress(java.net.SocketAddress address)
          Set the listen address which the acceptor bind with.
 void setListenPort(int port)
          Set the listen port which the acceptor bind with.
 void setReuseAddress(boolean b)
          Enable/disable the SO_REUSEADDR socket option.
 void start()
          Start acceptor.
 

Method Detail

getSessionType

SessionType getSessionType()
Get the session type of the session accepted by the acceptor.

Returns:
session type

getAcceptorHandler

SessionAcceptorHandler getAcceptorHandler()
Get the acceptor handler associated with this acceptor.

Returns:
session acceptor handler

setAcceptorHandler

void setAcceptorHandler(SessionAcceptorHandler handler)
Set the acceptor handler associated with this acceptor.

Parameters:
handler - session acceptor handler

setListenAddress

void setListenAddress(java.net.SocketAddress address)
Set the listen address which the acceptor bind with.

Parameters:
address - the local address
Throws:
java.lang.IllegalStateException

getListenAddress

java.net.SocketAddress getListenAddress()
Get the listen address which the accpetor bind with.

Returns:
the local address

setListenPort

void setListenPort(int port)
Set the listen port which the acceptor bind with.

Parameters:
port - the local port
Throws:
java.lang.IllegalStateException

getListenPort

int getListenPort()
Get the listen port which the acceptor bind with.

Returns:
the local port

setBacklog

void setBacklog(int backlog)
Set the maximum queue length for incoming connection. If the value passed equal or less than 0, then the default value will be assumed.

Parameters:
backlog - the maximum length of the queue

getBacklog

int getBacklog()
Get the maximum queue length for incoming connection. If the returned value equal or less than 0, then the default value will be assumed.

Returns:
the maximum length of the queue

setReuseAddress

void setReuseAddress(boolean b)
Enable/disable the SO_REUSEADDR socket option.

Parameters:
b - whether to enable or disable the socket option

isReuseAddress

boolean isReuseAddress()
Tests if SO_REUSEADDR is enabled.

Returns:
a boolean indicating whether or not SO_REUSEADDR is enabled

isStarted

boolean isStarted()
Acceptor is started.

Returns:
is started

start

void start()
Start acceptor.

Throws:
java.lang.IllegalStateException

close

void close()
Close acceptor.


getAcceptedCount

int getAcceptedCount()
Get accepted session count.

Returns:
accepted session count