There's a network-server programming pattern which is so popular that it's the canonical approach towards writing network servers: This design is easy to recognise: The main loop waits for some event, then dispatches based on the file descriptor and state that the file descriptor is in. At one point it was in vogue to actually fork() so that each file descriptor could be handled by a different thr
![fast-servers](https://cdn-ak-scissors.b.st-hatena.com/image/square/0c8cbbf3a35203349209254ec46e41879377ef7a/height=288;version=1;width=512/http%3A%2F%2Fgeocar.sdf1.org%2Ffast-net-annotated.png)