public static void main(String[] args) throws Exception {
	playerNo = Integer.parseInt(args[0].trim());
	int port = portOffset + playerNo;
	
	Socket socket = new Socket("localhost", port);
	BufferedReader in = 
	    new BufferedReader(new InputStreamReader(socket.getInputStream()));
	PrintWriter out = 
	    new PrintWriter(socket.getOutputStream(), true);
	
	out.print("My name is " + name);
	out.flush();

	char[] cbuf = new char[inputLength];
	String input;

	while(true) {
		try {
			if (in.ready()) {
				in.read(cbuf, 0, inputLength);
				input = new String(cbuf);
				input = input.trim();
				receive(input);
				if(inputPrompt.matcher(input).find()) {
					out.print(getAction(input));
					out.flush();
				} else if (input.equals("SHUTDOWN")) {
					socket.close();
					System.exit(0);
				}
			}
		} catch(Exception e) {
			System.out.println("Caught exception: ");
			e.printStackTrace();
			socket.close();
			System.exit(0);
		}
	}
    }