Fix the socket closure without busylooping
Use the local "x" rather than a clunky double-deref