/* * Salamander Transport Layer * * Michael J. Willis (violator@umich.edu) * * $Workfile: SalClientTest.java $ * $Author: rmalan $ * $Date: 1997/07/16 03:08:51 $ * $Revision: 1.4 $ */ /* * This file shows a very simple example of how to use the Salamander Transport * Layer in a java application. * The file contains two class definitions. The SalDataQueueTest class handles * the receipt of actual data from the server, while the SalClientTest class * performs all control-oriented communication with the server. */ import Salamander.*; // the Salamander package contains all necessary classes //package Salamander; import java.util.*; import java.io.*; /** * This SalClientTest class is a driver to demonstrate the instantiation * and use of a SalConnection object for the purpose of connecting to * the Salamander server. */ public class SalClientTest { /** * main is declared so that this example can be run directly * as an application */ public static void main(String arg[]) { // turn on internal diagnostics SAL.enableTrace(); // Obtain a SalConnection object. Note that the constructor // of SalConnection is not public, thus this is the only way // to obtain a SalConnection object. // In this simple example, we pass no parameters to getSalConnection() // so that defaults of "lorax.eecs.umich.edu" and 8086 will be used. SalConnection connect = SalConnection.getSalConnection(); if (null == connect) { System.err.println("SalClientTest: Could not get SalConnection()!"); System.exit(1); } // Create an instance of the SalDataQueueTest to obtain packets SalDataQueueTest queue = new SalDataQueueTest(); // Request a dataflow for the service named "test" from the // salamander server. By passing queue as the second parameter, // we have specified that the queue object will be called whenever // a new SalPacket in the "test" service has arrived. try { connect.startDataFlow(SalProperties.ALL_SALAMANDER_DATA, queue); connect.startDataFlow("test", queue); } catch (SalException e) { SAL.error("SalClientTest: Could not start data flow!"); } SAL.trace("Started data flow..."); // Just busy wait while the SalDataQueueTest object gets called... while (true) { try { Thread.currentThread().sleep(30); } catch (Exception e) { System.out.println("Sleep failed."); } } } }