org.sourceforge.jemm.comm.example.echo
Class EchoClient

java.lang.Object
  extended by org.sourceforge.jemm.comm.example.echo.EchoClient
All Implemented Interfaces:
EchoClientIF

public class EchoClient
extends java.lang.Object
implements EchoClientIF

A simple test client for sending echo messages to an echo server.


Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Constructor Summary
EchoClient(ClientConnectionFactory connFactory)
           
EchoClient(java.lang.String hostname, int port)
          Creates an EchoClient with the given parameters.
 
Method Summary
 void asyncEchoReply(java.lang.String reply)
          Asynchronous server->client echo message.
 void close()
          Close the echo client/server connection.
 void sendAsyncEcho(java.lang.String message)
          Send an echo message asynchronously.
 java.lang.String sendEcho(java.lang.String message)
          Send an message to the echo server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

EchoClient

public EchoClient(java.lang.String hostname,
                  int port)
           throws ConnectionException
Creates an EchoClient with the given parameters.

Parameters:
hostname - The target echo server host name.
port - The target echo server port.
Throws:
IOException - On connection error.
ConnectionException

EchoClient

public EchoClient(ClientConnectionFactory connFactory)
           throws ConnectionException
Throws:
ConnectionException
Method Detail

sendEcho

public java.lang.String sendEcho(java.lang.String message)
Send an message to the echo server.

Parameters:
message - The message to send to the echo server
Returns:
The reply from the echo server

sendAsyncEcho

public void sendAsyncEcho(java.lang.String message)
Send an echo message asynchronously. Replies are received by processServerMessage method.

Parameters:
message - The message to send.

asyncEchoReply

public void asyncEchoReply(java.lang.String reply)
Description copied from interface: EchoClientIF
Asynchronous server->client echo message.

Specified by:
asyncEchoReply in interface EchoClientIF
Parameters:
reply - The reply given by the server.

close

public void close()
Close the echo client/server connection.



Copyright © 2009. All Rights Reserved.