make sure messages are sent only on connected sockets.