[erlang-questions] Sending message to process already listening on a socket

Ben Hood 0x6e6562@REDACTED
Wed Aug 1 00:48:55 CEST 2007


Thanks for you help.

On 7/31/07, Matthias Lang <matthias@REDACTED> wrote:
>
> 1. Yes, messages are queued up until consumed.

I've been wondering about the formal semantics of erlang message
passing. Do you know of a reference where this is described in more
detail (like a language or VM spec), or do you just have to read the
source code?

> 3. If your message handling starts getting complicated and you
>    complicate your code to try and prevent blocking, then that's
>    often a sign that you're trying to get one process to solve a
>    problem which would be more cleanly solved by two or more processes.

Fair point. The code up until now was receiving frames from the socket
and then based on frame content, was dispatching to different
consuming processes. The routing decision was based on a channel
number in the frame for which there was a channel-to-pid mapping in
the process dictionary. I was just trying to find a way to register
new processes for new channel numbers with the process implementing
the loop. I ended up solving this by doing a short blocking receive on
the process mailbox for a new registration if a got a cache miss from
the process dictionary, thereby only blocking the socket listener if
it didn't know what to do with the received data anyway. However, by
using the {active, once} option, I could probably listen for new
process registrations more elegantly.

Thanks,

Ben



More information about the erlang-questions mailing list