[erlang-questions] Where can I use gen_server?

Bengt Kleberg bengt.kleberg@REDACTED
Wed Apr 1 16:12:12 CEST 2009


Greetings,

If you start a gen_server with start_link() it will take its clients
with it. If you start with start() the clients will remain.


bengt

On Mon, 2009-03-30 at 19:29 -0700, ryeguy wrote:
> 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?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list