abstract class AbstractSocketServer extends AbstractLogEnabledInstrumentableStartable
| Modifier and Type | Field and Description |
|---|---|
private int |
m_backlog
The backlog to assign to the server socket.
|
private java.net.InetAddress |
m_bindAddr
The address to bind the port server to.
|
private org.apache.excalibur.instrument.CounterInstrument |
m_instrumentConnects
Number of times that the server socket is connected to.
|
private org.apache.excalibur.instrument.CounterInstrument |
m_instrumentDisconnects
Number of times that a connection socket disconnects.
|
private org.apache.excalibur.instrument.ValueInstrument |
m_instrumentOpenSockets
Number of sockets that are connected at any given time.
|
private java.util.List |
m_openSockets
Used to track the number of open sockets.
|
private int |
m_port
The port to listen on for connections.
|
private java.lang.Object |
m_semaphore
Semaphore used to synchronize actions contained in this class.
|
private java.net.ServerSocket |
m_serverSocket
Reference to the ServerSocket.
|
private long |
m_shutdownTimeout
The time in ms after the component starts to shutdown that sockets
will have to shutdown on their own before they are closed.
|
private int |
m_soTimeout
The SO_TIMEOUT to use for client sockets.
|
private boolean |
m_started
Flag which keeps track of when the server has been started.
|
| Constructor and Description |
|---|
AbstractSocketServer(int port,
java.net.InetAddress bindAddress)
Creates a new AbstractSocketServer.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
getSoTimeout() |
protected abstract void |
handleSocket(java.net.Socket socket)
Handle a newly connected socket.
|
private void |
handleSocketInner(java.net.Socket socket)
Keeps track of instrumentation related to the life of a socket as well
as handles any errors encountered while handling the socket in the
user code.
|
protected void |
runner()
Runner method that will be called when the component is started.
|
void |
start()
Starts the runner thread.
|
protected void |
stopRunner()
Called when the component is being stopped, the isStopping method will
always return true when this method is called.
|
isStopping, run, stopaddChildInstrumentable, addInstrument, getChildInstrumentables, getInstrumentableName, getInstruments, setInstrumentableNameprivate java.lang.Object m_semaphore
private int m_port
private int m_backlog
private java.net.InetAddress m_bindAddr
private int m_soTimeout
private long m_shutdownTimeout
private boolean m_started
private java.net.ServerSocket m_serverSocket
private java.util.List m_openSockets
private org.apache.excalibur.instrument.CounterInstrument m_instrumentConnects
private org.apache.excalibur.instrument.ValueInstrument m_instrumentOpenSockets
private org.apache.excalibur.instrument.CounterInstrument m_instrumentDisconnects
public AbstractSocketServer(int port,
java.net.InetAddress bindAddress)
port - The port on which the server will listen.bindAddress - The address on which the server will listen for
connections.public void start()
throws java.lang.Exception
start in interface org.apache.avalon.framework.activity.Startablestart in class AbstractLogEnabledInstrumentableStartablejava.lang.Exception - If there are any problems.protected void stopRunner()
throws java.lang.Exception
stopRunner in class AbstractLogEnabledInstrumentableStartablejava.lang.Exception - If there are any problemsprotected void runner()
runner in class AbstractLogEnabledInstrumentableStartableprotected abstract void handleSocket(java.net.Socket socket)
socket - Newly connected Socket to be handled.private void handleSocketInner(java.net.Socket socket)
socket - The socket to be handled.protected int getSoTimeout()