On the client, always reserve at least two pieces of data so we can form a line. On the server, update the assert for a false positive.
A few proper shutdown procedures for the client.
Use a non-blocking socket to void using pthread_cancel, which is not available on Android.