why would socket.write cause an assertion error?