/*This code written by Nishant Agarwal
  Jul 12th, 2004
  nishant@purecode.us
*/

package server;

import java.io.*;
import java.net.*;

public class MyServer {
    public static void main(String[] argv) throws IOException {
        
        //Resources we need
        ServerSocket st = null;
        InetAddress addr = null; 
        boolean isRunning = true; 

        //initialze the resources
        try {
            st = new ServerSocket(51211);
            System.out.println("Server connected on host " +
                               addr.getLocalHost() + " on port " +
                               st.getLocalPort());                       
	} catch (UnknownHostException e) {
            System.err.println("Could not create sockets in server: " +
                               e.getMessage());
            e.printStackTrace();
            System.exit(-1);
	} 

        //now keep waiting for requests, spawn a thread 
        //to do the work whenever you get request
        while(isRunning == true) {
            new MyThread(st.accept()).t.start();
	}
    }
}
