check is socket is connected before sending data