public static void processAndSend(Socket s, String str) throws IOException
	{
		BufferedInputStream in = new BufferedInputStream(s.getInputStream());
		DataOutputStream out = new DataOutputStream(s.getOutputStream());

		byte b[] = new byte[BUF_LEN];
		int bytesRead = 0;

		String toSend = parseCommand(str);

		if(toSend == null)
			return;

		try
		{
			out.writeBytes(toSend + "\n");
		}
		catch( IOException ioe)
		{
			System.out.println("Could not send message to the server: " + ioe.getMessage());
			return;
		}
		/* Try to read a response from the server. Time out. */
		s.setSoTimeout(TIMEOUT);
		System.out.println("Received from server:");
		try
		{
			while( (bytesRead = in.read(b, 0, BUF_LEN)) > 0)
			{
				/* Display non-printable characters */
				for(int i = 0; i < bytesRead; i++)
				{
					/*
					   if(b[i] < 32 || b[i] > 126)
					   System.out.println("Unprintable character " + b[i] + ".");
					 */
				}

				b[bytesRead] = (byte)'\0';
				System.out.print(new String(b));
				bytesRead = 0;
			}
			System.out.println();
		}
		catch(SocketException se)
		{
			if(se.getMessage().equals("Connection reset"))
				return;
			else
			{
				System.out.println("Could not read from or write to the socket: " + se.getMessage());
				return;
			}

		}
		catch(SocketTimeoutException ste)
		{
			System.out.println("Timed out after " + TIMEOUT +
					"ms. No more bytes are coming from the server.");
		}
		catch(ArrayIndexOutOfBoundsException aie)
		{
			if(bytesRead < 0 )
				System.out.println("Error reading data from the server: " + aie.getMessage() );
			else
			{
				//This is most probably due to a buffer overflow.
				System.out.println("The message sent by the server is larger than the receive buffer.");
				//Replace the last byte in the buffer with the null termination character
				//and display part of the received contents
				b[(BUF_LEN - 1)] = '\0';
				System.out.println("Buffer Contents: ");
				System.out.println(new String(b));
			}
		}
		s.setSoTimeout(0);
	}