diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-25 22:18:58 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-25 22:18:58 +0000 |
commit | 7a5fe8ce23ac50450b804cf0183c773565ae7cef (patch) | |
tree | 220a38a6627619d1386897d42757a140b9de448f /java/examples/Logger/simple-server/LoggingClient.java | |
parent | 87b0987cad99cf45cd5d9e03cd1cefbaaec4ef2a (diff) | |
download | ATCD-ACE-4_4.tar.gz |
This commit was manufactured by cvs2svn to create branch 'ACE-4_4'.ACE-4_4
Diffstat (limited to 'java/examples/Logger/simple-server/LoggingClient.java')
-rw-r--r-- | java/examples/Logger/simple-server/LoggingClient.java | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/java/examples/Logger/simple-server/LoggingClient.java b/java/examples/Logger/simple-server/LoggingClient.java deleted file mode 100644 index e6ea986c011..00000000000 --- a/java/examples/Logger/simple-server/LoggingClient.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Main class that acts as an example logging client. - */ - -import java.io.*; -import java.net.*; -import JACE.SOCK_SAP.*; -import LogRecord; -import LoggerConstants; - -public class LoggingClient implements Runnable -{ - private String loggerHost_; - private int port_; - private int maxIter_; - private static final int DEFAULT_ITERATIONS = 10; - - public static void main(String[] args) - { - // Really need to put code in here to parse options - int iter; - int port; - String host; - - iter = (args.length > 0) ? Integer.parseInt(args[0]) - : DEFAULT_ITERATIONS; - port = (args.length > 1) ? Integer.parseInt(args[1]) - : LoggerConstants.DEFAULT_SERVER_PORT; - host = (args.length > 2) ? args[2] - : LoggerConstants.DEFAULT_SERVER_HOSTNAME; - - LoggingClient lc = new LoggingClient(iter, port, host); - lc.run(); - } - - public LoggingClient() - { - - this(DEFAULT_ITERATIONS, - LoggerConstants.DEFAULT_SERVER_PORT, - LoggerConstants.DEFAULT_SERVER_HOSTNAME); - } - - public LoggingClient(int iterations, int thePort, String theHost) - { - maxIter_ = iterations; - port_ = thePort; - loggerHost_ = theHost; - } - - public void run() - { - SOCKStream logger = new SOCKStream(); - SOCKConnector connector = new SOCKConnector(); - // INETAddr addr = new INETAddr(port_, loggerHost_); - - LogRecord rec = new LogRecord(9, 2, 0); - - try - { - connector.connect(logger, loggerHost_, port_); - - int oneSecond = 1000; - // Currently SOCKStream uses DataInputStream for its input stream, - // and PrintStream for its output stream. It probably ought to use - // DataOutputStream for the output stream for symmetry, or at least - // provide a mechanism for changing the type of the filter stream - // used (which might be better in the long run...give it the class - // id). - BufferedOutputStream bos = new BufferedOutputStream((OutputStream) logger.outputStream(), LogRecord.MAXLOGMSGLEN); - DataOutputStream dos = new DataOutputStream(bos); - - for (int i = 0; i < maxIter_; i++) - { - // Need to overload LogRecord.msgData to take a String - // argument so that it's easy to create instances with text - // inside. - rec.msgData("message = " + i); - try - { - dos.writeInt(rec.length()); - rec.streamOutTo(dos); - bos.flush(); - rec.print("localhost", true, System.err); - } - catch (IOException ex) { } - - try - { - Thread.sleep(oneSecond); - } - catch (InterruptedException ex) { } - } - - try { logger.close(); } catch (IOException ex) { } - - } - catch (SocketException ex) - { - System.err.println("socket exception: " + ex); - } - catch (IOException ex) - { - System.err.println("io exception: " + ex); - } - - } -} |