org.apache.tomcat.util.net

Class PoolTcpEndpoint

public class PoolTcpEndpoint extends Object implements Runnable

Handle incoming TCP connections. This class implement a simple server model: one listener thread accepts on a socket and creates a new worker thread for each incoming connection. More advanced Endpoints will reuse the threads, use queues, etc.

Author: James Duncan Davidson [duncan@eng.sun.com] Jason Hunter [jch@eng.sun.com] James Todd [gonzo@eng.sun.com] Costin@eng.sun.com Gal Shachor [shachor@il.ibm.com] Yoav Shapira

Field Summary
protected intlinger
protected intsocketTimeout
protected booleantcpNoDelay
Constructor Summary
PoolTcpEndpoint()
PoolTcpEndpoint(ThreadPool tp)
Method Summary
protected voidcloseServerSocket()
InetAddressgetAddress()
intgetBacklog()
TcpConnectionHandlergetConnectionHandler()
intgetCurrentThreadCount()
intgetCurrentThreadsBusy()
intgetMaxSpareThreads()
intgetMaxThreads()
intgetMinSpareThreads()
intgetPort()
intgetServerSoTimeout()
intgetSoLinger()
intgetSoTimeout()
StringgetStrategy()
booleangetTcpNoDelay()
intgetThreadPriority()
voidinitEndpoint()
booleanisPaused()
booleanisRunning()
voidpauseEndpoint()
voidresumeEndpoint()
voidrun()
The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
voidsetAddress(InetAddress inet)
voidsetBacklog(int backlog)
Allows the server developer to specify the backlog that should be used for server sockets.
voidsetConnectionHandler(TcpConnectionHandler handler)
voidsetMaxSpareThreads(int maxThreads)
voidsetMaxThreads(int maxThreads)
voidsetMinSpareThreads(int minThreads)
voidsetPort(int port)
voidsetServerSocket(ServerSocket ss)
voidsetServerSocketFactory(ServerSocketFactory factory)
voidsetServerSoTimeout(int i)
voidsetServerTimeout(int timeout)
Sets the timeout in ms of the server sockets created by this server.
voidsetSoLinger(int i)
voidsetSoTimeout(int i)
voidsetStrategy(String strategy)
voidsetTcpNoDelay(boolean b)
voidsetThreadPriority(int threadPriority)
voidstartEndpoint()
voidstopEndpoint()
protected voidunlockAccept()

Field Detail

linger

protected int linger

socketTimeout

protected int socketTimeout

tcpNoDelay

protected boolean tcpNoDelay

Constructor Detail

PoolTcpEndpoint

public PoolTcpEndpoint()

PoolTcpEndpoint

public PoolTcpEndpoint(ThreadPool tp)

Method Detail

closeServerSocket

protected void closeServerSocket()

getAddress

public InetAddress getAddress()

getBacklog

public int getBacklog()

getConnectionHandler

public TcpConnectionHandler getConnectionHandler()

getCurrentThreadCount

public int getCurrentThreadCount()

getCurrentThreadsBusy

public int getCurrentThreadsBusy()

getMaxSpareThreads

public int getMaxSpareThreads()

getMaxThreads

public int getMaxThreads()

getMinSpareThreads

public int getMinSpareThreads()

getPort

public int getPort()

getServerSoTimeout

public int getServerSoTimeout()

getSoLinger

public int getSoLinger()

getSoTimeout

public int getSoTimeout()

getStrategy

public String getStrategy()

getTcpNoDelay

public boolean getTcpNoDelay()

getThreadPriority

public int getThreadPriority()

initEndpoint

public void initEndpoint()

isPaused

public boolean isPaused()

isRunning

public boolean isRunning()

pauseEndpoint

public void pauseEndpoint()

resumeEndpoint

public void resumeEndpoint()

run

public void run()
The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.

setAddress

public void setAddress(InetAddress inet)

setBacklog

public void setBacklog(int backlog)
Allows the server developer to specify the backlog that should be used for server sockets. By default, this value is 100.

setConnectionHandler

public void setConnectionHandler(TcpConnectionHandler handler)

setMaxSpareThreads

public void setMaxSpareThreads(int maxThreads)

setMaxThreads

public void setMaxThreads(int maxThreads)

setMinSpareThreads

public void setMinSpareThreads(int minThreads)

setPort

public void setPort(int port)

setServerSocket

public void setServerSocket(ServerSocket ss)

setServerSocketFactory

public void setServerSocketFactory(ServerSocketFactory factory)

setServerSoTimeout

public void setServerSoTimeout(int i)

setServerTimeout

public void setServerTimeout(int timeout)
Sets the timeout in ms of the server sockets created by this server. This method allows the developer to make servers more or less responsive to having their server sockets shut down.

By default this value is 1000ms.

setSoLinger

public void setSoLinger(int i)

setSoTimeout

public void setSoTimeout(int i)

setStrategy

public void setStrategy(String strategy)

setTcpNoDelay

public void setTcpNoDelay(boolean b)

setThreadPriority

public void setThreadPriority(int threadPriority)

startEndpoint

public void startEndpoint()

stopEndpoint

public void stopEndpoint()

unlockAccept

protected void unlockAccept()
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.