Fixed the case where multiple exceptions would render a socket unusable

Fixes #331
Test included.