
/**
   ut c.class in a folder k in CLASSPATH.
   CLASSPATH/k/c.class
   
   new c(String host,int port);                    // open connection
   Object k(String s);                            // execute string
   Object k(String f,Object x,...);               // call f[x;...]
   void close();                                  // close connection

   void ks(String s,Object x,...);                // asynchronous send
   Object k();                                    // thread-poll for pushed data
   
   class utilities:
   int c.t(Object x);     // type 
   int c.n(Object x);     // count
   void c.p(Object x);    // print
   
   k type         java type
   1(int)         Integer(Boolean,Date)
   2(float)       Double(Time Timestamp)
   3(char)        Byte
   4(sym)         String
   0(general)     Object[]
   -1(int)        int[]
   -2(float)      double[]
   -3(char)       byte[]
   -4(sym)        String[]
   6(nil)         null
   
   error           exception  
   
   for example,
   
   k.c c=new k.c();       // connect to localhost k -i 1
   
   1. call analytic
   
   c.k("\\l code");        // load analytic
   c.k("f",x,y,z);         // f[x;y;z]

   2. updates from server? polling thread.
   
   c.k("_w,:w");          // register for updates
   for(;;)u(c.k());       // u is your update function
   
   3. mix pull and push? make it all push. 
   
   c.ks("send me new page")

**/

/**
t: { [t1] (,(,(32;4)), (, (32;5))), (,(,(33;3)), (,(33;4)))}
**/

// adopted from: bondcalc client 1998-10-15 copyright kx systems

public class den2 { // k den2 -i 1235
  public static void main(String args[]) {

    try {
      k.c myobj = new k.c("localhost", 1235); // class k method c??
		// creates a new object myobj
      int arr[] = new int [6]; 
	arr[0] = 2;
	arr[1] = 3;
	arr[2] = 4;
	arr[3] = 5;
	arr[4] = 6;
	arr[5] = 2;
	// Now send in a message with arguments.
	// get a result.
      Object result[] = (Object[])myobj.k("process", arr);
      int arr2[] = (int[]) result[1];
      for (int i = 0; i < arr2.length; i++) {
	System.out.println("arr2[" + i + "] = " + arr2[i]);  
      }
   	System.out.println(arr2.length);

      myobj.close();
    }
    catch(Exception e) {
      System.out.println("exception " + e.getMessage() + e.toString());
    }
  }
}

