Class EchoServer
java.lang.Object
|
+--ocsf.server.AbstractServer
|
+--EchoServer
- public class EchoServer
- extends AbstractServer
This class overrides some of the methods in the abstract
superclass in order to give more functionality to the server.
Field Summary |
static int |
DEFAULT_PORT
The default port to listen on. |
Constructor Summary |
EchoServer(int port)
Constructs an instance of the echo server. |
Method Summary |
void |
handleMessageFromClient(java.lang.Object msg,
ConnectionToClient client)
This method handles any messages received from the client. |
static void |
main(java.lang.String[] args)
This method is responsible for the creation of
the server instance (there is no UI in this phase). |
protected void |
serverStarted()
This method overrides the one in the superclass. |
protected void |
serverStopped()
This method overrides the one in the superclass. |
Methods inherited from class ocsf.server.AbstractServer |
clientConnected,
clientDisconnected,
clientException,
close,
getClientConnections,
getNumberOfClients,
getPort,
isListening,
listen,
listeningException,
receiveMessageFromClient,
run,
sendToAllClients,
serverClosed,
setBacklog,
setPort,
setTimeout,
stopListening |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
DEFAULT_PORT
public static final int DEFAULT_PORT
- The default port to listen on.
EchoServer
public EchoServer(int port)
- Constructs an instance of the echo server.
- Parameters:
port
- The port number to connect on.
handleMessageFromClient
public void handleMessageFromClient(java.lang.Object msg,
ConnectionToClient client)
- This method handles any messages received from the client.
- Parameters:
msg
- The message received from the client.client
- The connection from which the message originated.- Overrides:
- handleMessageFromClient in class AbstractServer
serverStarted
protected void serverStarted()
- This method overrides the one in the superclass. Called
when the server starts listening for connections.
- Overrides:
- serverStarted in class AbstractServer
serverStopped
protected void serverStopped()
- This method overrides the one in the superclass. Called
when the server stops listening for connections.
- Overrides:
- serverStopped in class AbstractServer
main
public static void main(java.lang.String[] args)
- This method is responsible for the creation of
the server instance (there is no UI in this phase).
- Parameters:
args[0]
- The port number to listen on. Defaults to 5555
if no argument is entered.