Literally, I was correct in saying that a gen_server can’t handle multiple clients *concurrently*. But normally this isn’t an issue since casting is so quick (since its a one-way message). If you want a gen_server to begin processing a message and be able to send back to the caller, I would spawn off the long running process, store the From parameter of `gen_server:call` and manually use `gen_server:reply` to reply via the spawned process.

To put this into a clearer example (I hope), imagine having a math server (based on gen_server) and there is a call which calculates all the primes up to `n`. For certain large n, this process can take quite awhile, so instead of doing all the calculations in the math server process, I would do something like the following:

handle_call({primes, N}, From, State) -> spawn(?MODULE, calculate_primes, [From, N]), {noreply, State}. calculate_primes(From, N) -> Primes = [], % Use some method of calculating prime numbers... gen_server:reply(From, {primes, Primes}).

Hopefully the example above poses a fairly obvious solution. As you can see in handle_call, since it spawns off the calculation work, it is able to become ready to handle more calls/casts/etc. right away. Then, when the calculate_primes method ends, it explicitly sends the respond back to the caller.

Mitchell

]]>