FileDocCategorySizeDatePackage
IntgenClient.javaAPI DocExample1157Sun Dec 12 10:53:34 GMT 2004None

IntgenClient

public class IntgenClient extends Object

Fields Summary
public static int
DEFAULT_PORT
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

  
       
  
    if (args.length == 0) {
      System.out.println("Usage: java IntgenClient host [port]"); 
      return;
    }  
  
    int port;
    try {
      port = Integer.parseInt(args[1]);
    }
    catch (Exception ex) {
      port = DEFAULT_PORT;   
    }
    
    try {
      SocketAddress address = new InetSocketAddress(args[0], port);
      SocketChannel client  = SocketChannel.open(address);
      ByteBuffer    buffer  = ByteBuffer.allocate(4);
      IntBuffer     view    = buffer.asIntBuffer();
      
      for (int expected = 0; ; expected++) {
        client.read(buffer);
        int actual = view.get();
        buffer.clear();
        view.rewind();
        
        if (actual != expected) {
          System.err.println("Expected " + expected + "; was " + actual);
          break;
        }
        System.out.println(actual);
      }     
    }
    catch (IOException ex) {
        ex.printStackTrace();   
    }