Only send data when socket is open.