001: package com.quadcap.net.server;
002:
003: /* Copyright 1999 - 2003 Quadcap Software. All rights reserved.
004: *
005: * This software is distributed under the Quadcap Free Software License.
006: * This software may be used or modified for any purpose, personal or
007: * commercial. Open Source redistributions are permitted. Commercial
008: * redistribution of larger works derived from, or works which bundle
009: * this software requires a "Commercial Redistribution License"; see
010: * http://www.quadcap.com/purchase.
011: *
012: * Redistributions qualify as "Open Source" under one of the following terms:
013: *
014: * Redistributions are made at no charge beyond the reasonable cost of
015: * materials and delivery.
016: *
017: * Redistributions are accompanied by a copy of the Source Code or by an
018: * irrevocable offer to provide a copy of the Source Code for up to three
019: * years at the cost of materials and delivery. Such redistributions
020: * must allow further use, modification, and redistribution of the Source
021: * Code under substantially the same terms as this license.
022: *
023: * Redistributions of source code must retain the copyright notices as they
024: * appear in each source code file, these license terms, and the
025: * disclaimer/limitation of liability set forth as paragraph 6 below.
026: *
027: * Redistributions in binary form must reproduce this Copyright Notice,
028: * these license terms, and the disclaimer/limitation of liability set
029: * forth as paragraph 6 below, in the documentation and/or other materials
030: * provided with the distribution.
031: *
032: * The Software is provided on an "AS IS" basis. No warranty is
033: * provided that the Software is free of defects, or fit for a
034: * particular purpose.
035: *
036: * Limitation of Liability. Quadcap Software shall not be liable
037: * for any damages suffered by the Licensee or any third party resulting
038: * from use of the Software.
039: */
040:
041: import java.io.ByteArrayInputStream;
042:
043: import java.io.*;
044: import java.net.*;
045:
046: import java.util.Properties;
047:
048: import com.quadcap.util.Debug;
049:
050: /**
051: * Package level testing.
052: *
053: * @author Stan Bailes
054: */
055: public class Test {
056: static String tst = "Text: foo\r\nSpaz: bar\r\n\r\n";
057:
058: public static void main(String args[]) {
059: try {
060: ServerSocket ss = new ServerSocket(80, 143);
061: byte[] buf = new byte[11000];
062: while (true) {
063: Socket s = ss.accept();
064: InputStream in = s.getInputStream();
065: OutputStream out = s.getOutputStream();
066: in.read(buf);
067: out.write(buf, 0, buf.length);
068: s.close();
069: }
070: } catch (Throwable t) {
071: Debug.print(t);
072: }
073: }
074:
075: public static void main3(String args[]) {
076: try {
077: WorkerInputStream win = new WorkerInputStream(null);
078: win.reset(new ByteArrayInputStream(tst.getBytes()));
079: byte[] hbuf = new byte[1024];
080: int[] hoff = new int[16];
081: int cnt = win.readHeaders(hbuf, hoff);
082: System.out.println("cnt = " + cnt);
083: int hcnt = hoff[0];
084: for (int i = 0; i <= hcnt; i++) {
085: System.out.println("hoff[" + i + "] = " + hoff[i]);
086: }
087: System.out.println("win.read() = " + win.read());
088: } catch (Throwable t) {
089: Debug.print(t);
090: }
091: }
092:
093: public static void main2(String args[]) {
094: try {
095: Properties p = new Properties();
096: p.put("workerClass", "com.quadcap.net.server.SimpleWorker");
097: Server s = new Server(p, null);
098:
099: 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: }
|