|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.thread.ThreadService SK.gnome.dwarf.tcpip.Listener SK.gnome.dwarf.tcpip.TCPListener
Service for receiving client connections.
It listenes on a specified port and address and passes the received connections
to the TCPIPServer
for further processing.
Field Summary | |
protected int |
backlog
The server socket queue size. |
protected java.net.ServerSocket |
socket
The server socket. |
Fields inherited from class SK.gnome.dwarf.tcpip.Listener |
address, allowedHosts, deniedHosts, port |
Fields inherited from class SK.gnome.dwarf.thread.ThreadService |
daemon, thread |
Fields inherited from class SK.gnome.dwarf.GenericService |
initParameters, parent |
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary | |
TCPListener(java.lang.String name)
Creates a new TCPListener. |
Method Summary | |
protected boolean |
enableThread()
Enables or disables the service thread. |
protected void |
finish()
Waits for the thread to complete. |
protected java.net.ServerSocket |
getServerSocket()
Returns the server socket. |
void |
init(Server parent)
Initializes the service. |
protected void |
loop()
Performs the listening operation. |
void |
setBacklog(int backlog)
Sets the server socket queue size. |
void |
setDumpDir(java.io.File dir)
Sets the directory where to dump the socket streams. |
Methods inherited from class SK.gnome.dwarf.tcpip.Listener |
acceptHost, setAddress, setAllowedHosts, setDeniedHosts, setPort |
Methods inherited from class SK.gnome.dwarf.thread.ThreadService |
run, setDaemon, shutdown, start, stop |
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int backlog
Default value: TCPIPConstants.TCPIP_DEFAULT_BACKLOG_SIZE
protected java.net.ServerSocket socket
getServerSocket()
Constructor Detail |
public TCPListener(java.lang.String name)
Method Detail |
public void setBacklog(int backlog)
backlog
- the backlog sizebacklog
public void setDumpDir(java.io.File dir)
If it is set to an existing directory, all client sockets created by this listener will dump their input and output streams to separate files in the specified directory.
dir
- the directorypublic void init(Server parent) throws ServiceException
Sets the socket
field to value returned by the getServerSocket()
method.
This method requires that the parent server is an instance of TCPIPServer
class.
init
in interface Service
init
in class GenericService
ServiceException
protected void finish()
It closes the socket
, which causes an interruption of the blocked listening
thread, so it can finish gracefully.
finish
in class ThreadService
protected boolean enableThread()
This method always returns true, so the new listening thread is always started.
enableThread
in class ThreadService
protected void loop()
Listenes on a specified port and address via the socket
. If a new client
connection is detected, first checks whether the connection should be accepted by invoking
the inherited Listener.acceptHost(InetAddress)
method and if the result is true,
it passes the socket to the parent server by calling its TCPIPServer.enqueue(Object)
method. In the case that the listener will not accept the connection, the socket is silently
closed and a warning message is written to the log.
loop
in class ThreadService
protected java.net.ServerSocket getServerSocket() throws ServiceException
Returns a socket for the listening. The returned socket will be bound to the Listener.port
.
If the Listener.address
field is null, the socket will listen on all available addresses,
otherwise it will listen of the specified address only. The socket is created using the
system-default ServerSocketFactory.
ServiceException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |