Eliminate the need to use pthread_cancel. Instead we'll poll on the server port as well as a self-pipe and use non-blocking accept. This fixes the memory leaks that pthread_cancel incurs since the thread isn't left gracefully.