Check we have a socket before sending messages.