[erlang-questions] Difference between gen_server and gen_fsm

David Terrell dbt@REDACTED
Thu Oct 11 19:23:14 CEST 2007


On Wed, Oct 10, 2007 at 10:00:02PM -0400, Jack Orenstein wrote:
> I'm going through the OTP design principles book and think that I am  
> missing the point of gen_fsm. The difference between gen_fsm and  
> gen_server seems to be a small syntactic one. Instead of handle_call  
> handling each kind of request, there is a function per FSM state. Not  
> having used gen_fsm yet, it seems that gen_fsm would lead to cleaner  
> code. But the two behaviors are so similar, I feel that I am either  
> missing the point of gen_fsm, or completely missing some aspect of  
> its behavior. Can someone please explain the distinction?

A gen_server should always respond to messages the same way. (not
necessarily exactly the same response, obviously).

A gen_fsm can respond to the same message in different ways depending
on its state, or not accept it at all.

-- 
David Terrell
dbt@REDACTED
((meatspace)) http://meat.net/



More information about the erlang-questions mailing list