| 1 package com.quadcap.net.server; 2 3 40 41 import java.io.ByteArrayInputStream ; 42 43 import java.io.*; 44 import java.net.*; 45 46 import java.util.Properties ; 47 48 import com.quadcap.util.Debug; 49 50 55 public class Test { 56 static String tst = "Text: foo\r\nSpaz: bar\r\n\r\n"; 57 58 public static void main(String args[]) { 59 try { 60 ServerSocket ss = new ServerSocket(80, 143); 61 byte[] buf = new byte[11000]; 62 while (true) { 63 Socket s = ss.accept(); 64 InputStream in = s.getInputStream(); 65 OutputStream out = s.getOutputStream(); 66 in.read(buf); 67 out.write(buf, 0, buf.length); 68 s.close(); 69 } 70 } catch (Throwable t) { 71 Debug.print(t); 72 } 73 } 74 75 public static void main3(String args[]) { 76 try { 77 WorkerInputStream win = new WorkerInputStream(null); 78 win.reset(new ByteArrayInputStream (tst.getBytes())); 79 byte[] hbuf = new byte[1024]; 80 int[] hoff = new int[16]; 81 int cnt = win.readHeaders(hbuf, hoff); 82 System.out.println("cnt = " + cnt); 83 int hcnt = hoff[0]; 84 for (int i = 0; i <= hcnt; i++) { 85 System.out.println("hoff[" + i + "] = " + hoff[i]); 86 } 87 System.out.println("win.read() = " + win.read()); 88 } catch (Throwable t) { 89 Debug.print(t); 90 } 91 } 92 93 public static void main2(String args[]) { 94 try { 95 Properties p = new Properties (); 96 p.put("workerClass", "com.quadcap.net.server.SimpleWorker"); 97 Server s = new Server(p, null); 98 99 p = new Properties (); 100 p.put("port", "80"); 101 p.put("queueDepth", "64"); 102 s.startAcceptor(p); 103 } catch (Exception e) { 104 e.printStackTrace(System.err); 105 } 106 } 107 108 } 109 | Popular Tags |