It turns up that making the network thing work correctly isn’t that easy. When the client is connected and the server quits, the recv call doesn’t terminate even though we send a signal to the thread.

However, when the client resets the connection (by quitting without disconnecting the proper way), the recv call terminates and sets errno to ECONNRESET.

Both cases should be handled correctly by the threads and the socket class. This includes joining the threads because one of the threads segfaults otherwise. Perhaps using different exception classes for different conditions (e.g. ECONNRESET) is a viable solution.

Apart from diagnosing this problem, a simple simulation was made to work today. It just moves the ball from side to side on the table.

Leave a Reply