public static void connectToChatRoom(String cHost, int cPort) throws IOException {

		Socket joinedClient =null;

		BufferedReader in;
		PrintWriter out = null;

	
		try {
			joinedClient = new Socket(cHost, cPort);
		} catch (IOException e) {
			System.out.println("Could not connect to peer ");
			return;
		}

		try { 
			joinedClient.setSoTimeout(30000);
		} catch (SocketException se) {
			System.err.println("Unable to set socket connection timeout ");
		}


		try {
			out = new PrintWriter(joinedClient.getOutputStream(), true);
			in = new BufferedReader(
					new InputStreamReader(joinedClient.getInputStream()));
		} catch (IOException e) {
			System.err.println(e);
			return;
		}

	
		BufferedReader standardIn = new BufferedReader(new InputStreamReader(
				System.in));

		
		System.out.println("Input '/exit' to disconnect or quit the chatroom\nInput a message to send data to chatroom:");

		String inMessage2;
		String outMessage2;


		while (true) {
			try {
				if (in.ready()) {
					inMessage2 = in.readLine(); 
					if (inMessage2.equals("Dics_From_Chat")) {
						System.out.println("A user has disconnected.");

					} else {
					
						System.out.println(inMessage2);
					}
				} else if (standardIn.ready()) {
					outMessage2 = standardIn.readLine(); 

					if (outMessage2.equals("/exit"))
					{
						System.out.println("Disconnecting from chatroom.");
						out.println("Dics_From_Chat");
					

						break;
					} else { 
						out.println(outMessage2);
					}

				}

			} catch (SocketException SE) { // Disconnect clients
				System.out.println("Connection timed out, standby ");
				joinedClient.close();
				
			}
		}

	}