Handle socket errors
Merge pull request #12 from roryoldershaw/1.x

Handle socket errors