Fix a segmentation fault when an initial connection attempt fails.
Merge pull request #5 from potatosalad/connect-segmentation-fault

Fix a segmentation fault when an initial connection attempt fails.