//---------------------------------------------------------------------- // Author: Matthias Lang (matthias@corelatus.com) // Created: January 2001 // // Use: // java Minimum // // gth-hostname: the GTH's hostname (or IP address) // // Demonstration of the shortest possible (well...) Java program which // can make the GTH do something useful. This causes the GTH to loop back // any signalling or audio on timeslot 4 of the first PCM link. // // The process never exits; you need to press ^C or equivalent to end it. //---------------------------------------------------------------------- import java.io.*; import java.net.*; public class Minimum { public static void main(String[] args) { final int PORT = 2089; int c; if (args.length != 1) throw new IllegalArgumentException("1. argument must be hostname"); try { String req = new String("" + "" + "" + "" + "" + ""); Socket sock = new Socket(args[0], PORT); DataOutputStream os = new DataOutputStream(sock.getOutputStream()); InputStream is = sock.getInputStream(); os.writeBytes("Content-type: text/xml\r\n"); os.writeBytes("Content-length: " + req.length() + "\r\n\r\n"); os.writeBytes(req); while (true) { c = is.read(); if (c == -1) return; System.out.print((char)c); } } catch (IOException e) { System.out.println(e); } } }