public static void main(String[] args)
	{
		// default values
		int portNumber = 27886;
		String serverAddress = "localhost";
		String username = "Anonymus";
		
		// depending of the number of arguments provided we fall through
		switch(args.length)
		{
			// > java Client username portNumber serverAddress
			case 3:
				serverAddress = args[2];
			// > java Client username portNumber
			case 2:
				try
				{
					portNumber = Integer.parseInt(args[1]);
				}
				catch(Exception e)
				{
					System.out.println("Invalid port number.");
					System.out.println("Usage is:  > java Client [username] [portNumber] [serverAddress]");
					return;
				}
			// > java Client username
			case 1:
				username = args[0];
			case 0:
				break;
			// ivalid number of arguments
			default:
				System.out.println("Usage is:  > java Client [username] [portNumber] [serverAddress]");
				return;
		}		
		
		// create the Client Object
		Client _client = new Client(serverAddress, portNumber, username);
		// test if we can start the connection to the server
		// if it failed, nothing we can do
		if(!_client.start())
			return;
		
		// wait for messages from user
		Scanner scan = new Scanner(System.in);
		
		// loop forever for message from the user
		while(true)
		{
			System.out.println("> ");
			// read message from user
			String msg = scan.nextLine();
			// logout if message is LOGOUT
			if(msg.equalsIgnoreCase("LOGOUT"))
			{
				_client.sendMessage(new ChatMessage(ChatMessage.LOGOUT, ""));
				// break to do the disconnect
				break;
			}
			// message WHOISIN
			else if(msg.equalsIgnoreCase("WHOISIN"))
			{
				_client.sendMessage(new ChatMessage(ChatMessage.WHOISIN, ""));
			}
			// default to ordinary message
			else
			{
				_client.sendMessage(new ChatMessage(ChatMessage.MESSAGE, msg));
			}
		}
		// done disconnect
		scan.close();
		_client.disconnect();		
	}