First fix for bad connections errors

On a very bad connection this error can occur: "attempt to index field
'sock' (a nil value)"
Merge pull request #6 from Zillion01/master

First fix for bad connection