// SimpleServerLoop.java: a simple server program that runs forever in a single thead
import java.net.*; 
import java.io.*;
public class SimpleServerLoop {
  public static void main(String args[]) throws IOException {
    // Register service on port 1234
    ServerSocket s = new ServerSocket(1234); 
    while(true)
    {
	    Socket s1=s.accept(); // Wait and accept a connection
	    // Get a communication stream associated with the socket
	    OutputStream s1out = s1.getOutputStream();
	    DataOutputStream dos = new DataOutputStream (s1out);
	    // Send a string! 
	    dos.writeUTF("Hi there");
	    // Close the connection, but not the server socket
	    dos.close();
	    s1out.close();
	    s1.close();
    }
  }
}

