Ensure connect callback is invoked on premature socket hangup

Closes #534

The patch was tested against 2.11.1