|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.mtu.eggplant.util.network.TCPServer
public class TCPServer
Simple TCP echo server.
Field Summary | |
---|---|
static int |
DEFAULT_PORT
|
Constructor Summary | |
---|---|
TCPServer()
default constructor. |
|
TCPServer(int port)
Create a ServerSocket to listen for connections on If port < 0 or port > 65535 port defaults to DEFAULT_PORT. |
Method Summary | |
---|---|
protected Socket |
getSocket()
get the actual socket |
void |
initializeConnection()
Actually make the connection and wait for data. |
static void |
main(String[] args)
|
void |
print(String message)
print something to the socket. |
protected boolean |
processData(String line)
do something with a line of input. |
String |
readLine()
read a line from the socket |
void |
run()
The body of the server thread. |
protected void |
setSocket(Socket s)
set the actual socket. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT
Constructor Detail |
---|
public TCPServer()
public TCPServer(int port)
port
- the port to listen onMethod Detail |
---|
public void run()
initializeConnection()
.
run
in interface Runnable
public void initializeConnection()
protected boolean processData(String line)
line
- the input
public void print(String message)
message
- the message, if not connected nothing happenspublic String readLine() throws IOException
IOException
protected Socket getSocket()
protected void setSocket(Socket s)
s
- the socketpublic static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |