PROTIP: setting the timeout of socket_select to '0' makes it return immediately. This makes the while loop spin continuously and it chews up CPU like a mother.
Setting it to NULL makes it block indefinitely. As a result, it no longer chews up 100% of CPU.