Handle connection errors
Use getopt and encapsulate settings

Since argparse was only introduced in 2.7/3.2, use getopt so that older
versions will work. Also, encapsulate all the settings methods into a
single class.
Support older Python (<2.7)

Just some small changes to support the older versions of python that
are still being used.