|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iglu.net.PortServer
The PortServer creates a socket which listens on the port specified in the constructor. When a client connects, it creates a new socket on another port for communication with the client. Then is creates and starts a ClienHandler thread to deal with the client. It continues until keepGoing is set to false. See iglu.examples.PortServerExample.java for a simple example.
ProxyServerExample
Field Summary | |
protected java.net.InetAddress |
addr
Which host the port server is running on |
(package private) ClientCreator |
clientCreator
the object that knows how to create the client threads to handle the clients. |
protected boolean |
keepGoing
Whether or not to keep looking for more clients. |
protected java.lang.Integer |
port
Which port the server is running on |
(package private) java.net.ServerSocket |
serverSocket
the server which watches the port listening for new clients |
Constructor Summary | |
PortServer(java.net.InetAddress addr,
java.lang.Integer port,
ClientCreator ncc)
this constructor opens and listens on the indicated port at the indicated address. |
Method Summary | |
void |
clientDone(ClientHandler nc)
Post-processing of the clientHandler. |
protected void |
clientReady(ClientHandler nc)
Pre-processing of the clientHandler. |
java.net.InetAddress |
getHost()
Which host the port server is running on |
java.lang.Integer |
getPort()
Which port the server is running on |
ClientHandler |
getWatcher(java.net.Socket client,
PortServer ms)
This returns a ClientHandler which handles the input from the client. |
void |
go()
Starts watching the socket. |
void |
stop()
quit looking for clients |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean keepGoing
java.net.ServerSocket serverSocket
ClientCreator clientCreator
protected java.lang.Integer port
protected java.net.InetAddress addr
Constructor Detail |
public PortServer(java.net.InetAddress addr, java.lang.Integer port, ClientCreator ncc)
addr
- The internet address of the machine containing the server.port
- The port to listen on.ncc
- The ClientCreator.Method Detail |
public void go()
protected void clientReady(ClientHandler nc)
nc
- The clientHandler being pre-processedpublic void clientDone(ClientHandler nc)
nc
- The ClientHandler being wrapped up.public ClientHandler getWatcher(java.net.Socket client, PortServer ms) throws java.io.IOException
client
- ms
-
java.io.IOException
public java.net.InetAddress getHost()
public java.lang.Integer getPort()
public void stop()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |