Catch socket errors on write
Merge pull request #1 from evax/master

Enables us to catch "[Errno 110] Connection timed out" etc. Thanks @evax