The landlord first returns the number of result sets returned by this request to the client with a number, and then uses this number to control the number of loops, so that there will be no infinite loop.
I haven't written similar code, but I guess because you can get the output stream from the server every time, the while loop won't quit.