public static void main(String[] args) {
		if (args.length != 2) {
			System.out.println(USAGE);
			System.exit(0);
		}

		String name = args[0];
		InetAddress addr = null;
		int port = 0;
		ServerSocket server = null;
		Socket sock = null;

		// parse args[1] - the port
		try {
			port = Integer.parseInt(args[1]);
		} catch (NumberFormatException e) {
			System.out.println(USAGE);
			System.out.println("ERROR: port " + args[2] + " is not an integer");
			System.exit(0);
		}

		// try to open a Socket to the server
		try {
			server = new ServerSocket(port);
			sock = server.accept();
		} catch (IOException e) {
			System.out.println("ERROR: could not create a serversocket on port " + port);
		}

		// create Peer object and start the two-way communication
		try {
			Peer client = new Peer(name, sock);
			Thread streamInputHandler = new Thread(client);
			streamInputHandler.start();
			client.handleTerminalInput();
			client.shutDown();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}