--- /dev/null
+package org.ibex.net.ssl;
+
+import org.ibex.net.SSL;
+import java.io.*;
+
+public class Test {
+ public static void main(String[] args) throws Exception {
+ SSL.debugOn = true;
+ if(args.length < 2) { System.err.println("Usage: SSL host port"); }
+ String host = args[0];
+ int port = Integer.parseInt(args[1]);
+ SSL ssl = new SSL(host,port);
+ //ssl.setTLS(false);
+ ssl.getOutputStream().write(SSL.getBytes("GET / HTTP/1.0\r\nHost: " + host + "\r\n\r\n"));
+ cat(ssl.getInputStream());
+ ssl.close();
+
+ // try to resume
+ ssl = new SSL(host,port,ssl.getSessionState());
+ ssl.getOutputStream().write(SSL.getBytes("GET / HTTP/1.0\r\nHost: " + host + "\r\n\r\n"));
+ cat(ssl.getInputStream());
+ ssl.close();
+ }
+ private static void cat(InputStream is) throws IOException {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String line;
+ int count = 100;
+ try {
+ while((line = br.readLine()) != null && --count >= 0) System.out.println(line);
+ } catch(SSL.PrematureCloseExn e) { /* ignore */ }
+ }
+}