00001
package com.quadcap.net.server;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
import java.io.ByteArrayInputStream;
00042
00043
import java.io.*;
00044
import java.net.*;
00045
00046
import java.util.Properties;
00047
00048
import com.quadcap.util.Debug;
00049
00050
00051
00052
00053
00054
00055 public class Test {
00056 static String
tst =
"Text: foo\r\nSpaz: bar\r\n\r\n";
00057
00058 public static void main(String args[]) {
00059
try {
00060 ServerSocket ss =
new ServerSocket(80, 143);
00061 byte[] buf =
new byte[11000];
00062
while (
true) {
00063 Socket s = ss.accept();
00064 InputStream in = s.getInputStream();
00065 OutputStream out = s.getOutputStream();
00066 in.read(buf);
00067 out.write(buf, 0, buf.length);
00068 s.close();
00069 }
00070 }
catch (Throwable t) {
00071
Debug.print(t);
00072 }
00073 }
00074
00075 public static void main3(String args[]) {
00076
try {
00077
WorkerInputStream win =
new WorkerInputStream(null);
00078 win.
reset(
new ByteArrayInputStream(
tst.getBytes()));
00079 byte[] hbuf =
new byte[1024];
00080
int[] hoff =
new int[16];
00081
int cnt = win.
readHeaders(hbuf, hoff);
00082 System.out.println(
"cnt = " + cnt);
00083
int hcnt = hoff[0];
00084
for (
int i = 0; i <= hcnt; i++) {
00085 System.out.println(
"hoff[" + i +
"] = " + hoff[i]);
00086 }
00087 System.out.println(
"win.read() = " + win.
read());
00088 }
catch (Throwable t) {
00089
Debug.print(t);
00090 }
00091 }
00092
00093 public static void main2(String args[]) {
00094
try {
00095 Properties p =
new Properties();
00096 p.put(
"workerClass",
"com.quadcap.net.server.SimpleWorker");
00097
Server s =
new Server(p, null);
00098
00099 p =
new Properties();
00100 p.put(
"port",
"80");
00101 p.put(
"queueDepth",
"64");
00102 s.
startAcceptor(p);
00103 }
catch (Exception e) {
00104 e.printStackTrace(System.err);
00105 }
00106 }
00107
00108 }