Have the client detect when the server goes away.
Add code for the server to detect when the client disconnects.
Switch to the (really nice!) QsLog library.