package hc.adlrunner;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class ADLServer implements Runnable {
	private static final int ADL_PORT = 2525;

	private ServerSocket ss;

	private String[] args;

	public ADLServer(String[] args) throws IOException {
		this.ss = new ServerSocket(ADL_PORT);
		this.args = args;
	}

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		new ADLServer(args).run();
	}

	public void run() {
		try {
			while (true) {
				Socket s = ss.accept();
				System.out.println("Accepted connection from "
						+ s.getInetAddress().getHostAddress());
				new Thread(new ADLRunner(s, args)).start();
			}
		} catch (Throwable t) {
			t.printStackTrace();
		}
	}

}
