I had to write a cowboy stream handler for work this week, and in the process, I put together this little reference module with comments to use as a jumping off point for when I have to write these in the future. Someone pointed out that I should share it online, so here it is! Figured others might find a use for it.
There are two example implementations of ranch_protocol shipping with ranch. The tcp_echo one is very simplicistic, tcp_reverse is more advanced and implemented as a gen_statem.