Thu Sep 17 10:35:39 EDT 2015

Modular programming: separate listeners from handlers

If connection handling (accept) is abtracted away from listening, it
is possible to reload handlers without stopping the server.

Basically, what you want is a collection of pure functions in one
module to implement the behavior and state transitions, and another
one to call into this from a socket handler.

It might be time to switch to gen_server.