[erlang-questions] tcp data in a gen_fsm

Max Lapshin max.lapshin@REDACTED
Mon Nov 30 08:12:37 CET 2015


We have fully refused from using gen_fsm and especially in handling
protocol states in gen_fsm.

Everywhere we use something like:

handle_info({tcp, Socket, Input},  #state{protocol_state = S0} = State) ->
   {ok, OutputCommands, S1} = some_protocol:handle(Input, S0),
   ..handle somehow OutputCommands
  inet:setopts(Socket, [{active,once}]),
  {noreply, State#state{protocol_state = S1}}.


Such approach allows to record Input to file and write a test for output
commands. Also it allows more easily handle situation when there is more
than 1 command in Input packet.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151130/e5a651db/attachment.htm>


More information about the erlang-questions mailing list