Check if the socket is open
Fixes #1364