[erlang-questions] Where can I use gen_server?

ryeguy ryeguy1@REDACTED
Tue Mar 31 04:29:43 CEST 2009

I'm making a game server, and I just can't see where I would want to
use a gen_server. I'm not set on using one, but I don't want to skimp
on using one where it would make it easier to program this app.

What I have per node is this: I have 1 process accepting new
connections, which spawns a new process for each new client. For each
packet that comes in, a new process is spawned to handle it and then
it sends the result back to the listening process and terminates.

It sounds like a good candidate for gen_server, but per the docs it
seems you want to use them when there is some shared resource that you
want to manage, and I don't see one. If I gave each client their own
gen_server, it wouldn't be good because if an erroneous packet was
sent that caused an exception, it would terminate their connection and
any other packets being processed for this client (since a gen_server
takes all of its spawned processes down with it, right?).

Is there any advantage to using gen_server in my situation?

More information about the erlang-questions mailing list