// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.*;
import java.net.*;

public class Loop {
   private final static int PORT = 80;
   public static void main(String[] arg) {
      ServerSocket ss = null;
      try {
         ss = new ServerSocket(PORT);
      } catch (IOException e) {
         e.printStackTrace();
         System.exit(0);
      }
      while(true) {
         try {
            Socket s = ss.accept();
            InputStream is = s.getInputStream();
            OutputStream os = s.getOutputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            PrintWriter pw = new PrintWriter(os);
            String req = br.readLine();
            pw.println("HTTP/1.0 200 OK");
            pw.println("Content-Type: text/plain");
            pw.println();
            pw.flush();
            for(int i = 0; ; i++) {
                pw.println("Line " + i);
                pw.flush();
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            //pw.close();
            //s.close();
         } catch (IOException e) {
             e.printStackTrace();
         }
      }
   }
}
