// WebClient derived from NetClient -- lars appel 22.feb.99 / 25.apr.99 import java.net.*; import java.io.*; class WebClient { // send a very simple http request and read response for displaying static final int PORT = 3001; public static void main( String args[] ) throws Exception { String host = (args.length >= 1) ? args[0] : "127.0.0.1"; String path = (args.length >= 2) ? args[1] : "/demo?a=1"; Socket sock = new Socket( host, PORT ); PrintWriter w = new PrintWriter (sock.getOutputStream(), true); // autoFlush BufferedReader r = new BufferedReader (new InputStreamReader (sock.getInputStream()) ); w.println ("GET " + path + " HTTP/1.0\n"); while (true) { String s = r.readLine(); if (s != null) System.out.println (s); else break; } r.close(); w.close(); sock.close(); } }