|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.web.miniserver.NetworkServer
public class 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 Web Programming from Prentice Hall and Sun Microsystems Press, http://www.corewebprogramming.com/. © 2001 Marty Hall and Larry Brown; may be freely used or adapted.
| Field Summary | |
|---|---|
protected int |
port
|
| 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 |
| Field Detail |
|---|
protected int port
| 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.
IOExceptionpublic int getMaxConnections()
public void setMaxConnections(int maxConnections)
public int getPort()
protected void setPort(int port)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||