Mostly a style thing, but I think the case statements in the Protocol could be more beneficial than the case statements. It keeps indentation down.
The main reason that I am bring this up is that none of the :gen_tcp.recv function calls deal with errors being returned. If you refactored the case statements into function calls, you could easily field the :gen_tcp:recv errors in a single function call, instead of dealing with the errors in each case statement.
Mostly a style thing, but I think the case statements in the Protocol could be more beneficial than the case statements. It keeps indentation down.
The main reason that I am bring this up is that none of the
:gen_tcp.recvfunction calls deal with errors being returned. If you refactored the case statements into function calls, you could easily field the:gen_tcp:recverrors in a single function call, instead of dealing with the errors in each case statement.