More improvements.

  - Made the listening port configurable.
  - Improved the log format.
  - Bug fix - the client socket isn't closed sometimes.
  - Efficiency improvement - logging happens only after the response is sent.