Backport some missed code for handling conn resets
Merge pull request #12 from alex/handle-conn-reset

Backport some missed code for handling conn resets