Check if the socket is alive before using it