|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectThreadedServer
org.mortbay.p2psockets.util.P2PThreadedServer
public class P2PThreadedServer
Threaded socket server modified for JXTA. This class listens at a socket and gives the connections received to a pool of Threads
The regular P2PThreadedServer is abstract; however, we have modified P2PThreadedServer to not be abstract so that an instance of it can be aggregated by P2PSocketListener. -- bkn3@columbia.edu
The properties THREADED_SERVER_MIN_THREADS and THREADED_SERVER_MAX_THREADS can be set to control the number of threads created.
| Constructor Summary | |
|---|---|
P2PThreadedServer(java.net.InetAddress address,
int port,
P2PSocketListener socketListener)
Construct for specific address and port. |
|
P2PThreadedServer(int port,
P2PSocketListener socketListener)
Construct for specific port. |
|
P2PThreadedServer(P2PSocketListener socketListener)
|
|
P2PThreadedServer(java.lang.String host,
int port,
P2PSocketListener socketListener)
Construct for specific address and port. |
|
| Method Summary | |
|---|---|
protected java.net.Socket |
acceptSocket(java.net.ServerSocket serverSocket,
int timeout)
Accept socket connection. |
java.lang.String |
getHost()
|
java.net.InetAddress |
getInetAddress()
|
InetAddrPort |
getInetAddrPort()
|
int |
getLingerTimeSecs()
|
int |
getMaxReadTimeMs()
|
int |
getPort()
|
java.net.ServerSocket |
getServerSocket()
|
void |
handle(java.lang.Object job)
Handle Job. |
protected void |
handleConnection(java.io.InputStream in,
java.io.OutputStream out)
Handle new connection. |
protected void |
handleConnection(java.net.Socket connection)
Handle new connection. |
protected java.net.ServerSocket |
newServerSocket(InetAddrPort address,
int acceptQueueSize)
New server socket. |
void |
open()
Open the server socket. |
void |
setHost(java.lang.String host)
|
void |
setInetAddress(java.net.InetAddress addr)
|
void |
setInetAddrPort(InetAddrPort address)
Set the server InetAddress and port. |
void |
setLingerTimeSecs(int ls)
|
void |
setMaxReadTimeMs(int ms)
Deprecated. maxIdleTime is used instead. |
void |
setPort(int port)
|
void |
start()
|
void |
stop()
|
protected void |
stopJob(java.lang.Thread thread,
java.lang.Object job)
Kill a job. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public P2PThreadedServer(P2PSocketListener socketListener)
public P2PThreadedServer(int port,
P2PSocketListener socketListener)
public P2PThreadedServer(java.net.InetAddress address,
int port,
P2PSocketListener socketListener)
public P2PThreadedServer(java.lang.String host,
int port,
P2PSocketListener socketListener)
throws java.net.UnknownHostException
java.net.UnknownHostException| Method Detail |
|---|
public java.net.ServerSocket getServerSocket()
public void setInetAddrPort(InetAddrPort address)
address - The Address to listen on, or 0.0.0.0:port for
all interfaces.public InetAddrPort getInetAddrPort()
public void setHost(java.lang.String host)
throws java.net.UnknownHostException
host -
java.net.UnknownHostExceptionpublic java.lang.String getHost()
public void setInetAddress(java.net.InetAddress addr)
addr - public java.net.InetAddress getInetAddress()
public void setPort(int port)
port - public int getPort()
public void setMaxReadTimeMs(int ms)
public int getMaxReadTimeMs()
public void setLingerTimeSecs(int ls)
ls - seconds to linger or -1 to disable linger.public int getLingerTimeSecs()
protected void handleConnection(java.io.InputStream in,
java.io.OutputStream out)
protected void handleConnection(java.net.Socket connection)
throws java.io.IOException
java.io.IOExceptionpublic void handle(java.lang.Object job)
job - A Connection.
protected java.net.ServerSocket newServerSocket(InetAddrPort address,
int acceptQueueSize)
throws java.io.IOException
address - Address and portacceptQueueSize - Accept queue size
java.io.IOException
protected java.net.Socket acceptSocket(java.net.ServerSocket serverSocket,
int timeout)
serverSocket - timeout - The time to wait for a connection. Normally
passed the ThreadPool maxIdleTime.
public void open()
throws java.io.IOException
java.io.IOException - if an error occurs
public void start()
throws java.lang.Exception
java.lang.Exception
public void stop()
throws java.lang.InterruptedException
java.lang.InterruptedException
protected void stopJob(java.lang.Thread thread,
java.lang.Object job)
thread - job - public java.lang.String toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||