|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--NetworkServer
A starting point for network servers. You'll need to override handleConnection, but in many cases listen can remain unchanged. NetworkServer uses SocketUtil to simplify the creation of the PrintWriter and BufferedReader.
Taken from Core Servlets and JavaServer Pages from Prentice Hall and Sun Microsystems Press, http://www.coreservlets.com/. © 2000 Marty Hall; may be freely used or adapted.
| Constructor Summary | |
NetworkServer(int port,
int maxConnections)
Build a server on specified port. |
|
| Method Summary | |
int |
getMaxConnections()
Gets the max connections server will handle before exiting. |
int |
getPort()
Gets port on which server is listening. |
protected void |
handleConnection(Socket server)
This is the method that provides the behavior to the server, since it determines what is done with the resulting socket. |
void |
listen()
Monitor a port for connections. |
void |
setMaxConnections(int maxConnections)
Sets max connections. |
protected void |
setPort(int port)
Sets port. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public NetworkServer(int port,
int maxConnections)
| Method Detail |
public void listen()
protected void handleConnection(Socket server)
throws IOException
This generic version simply reports the host that made the connection, shows the first line the client sent, and sends a single line in response.
public int getMaxConnections()
public void setMaxConnections(int maxConnections)
public int getPort()
protected void setPort(int port)
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
![]() |
|---|
| CSAJSP @ amazon.com |