SockFetch.java
import java.net.*;
import java.io.*;
/**
Simple Socket example -- fetch Web page using raw HTTP.
*/
public class SockFetch
{
public static void main(String[] argv)
{
String host = "bozoid.ace-net.com";
try {
Socket s = new Socket(host,80);
PrintWriter out =
new PrintWriter(s.getOutputStream());
BufferedReader in =
new BufferedReader(
new InputStreamReader(s.getInputStream()));
// Send HTTP request.
out.write("GET / HTTP/1.0\r\n\r\n");
out.flush();
s.shutdownOutput();
// Read HTTP response.
while (true) {
String line = in.readLine();
if (line == null)
break;
System.out.println(line);
}
// Play nice.
out.close();
in.close();
s.close();
}
catch (IOException ex) {
System.out.println(ex);
}
}
}