[erlang-questions] Semantics of send

Johan Montelius <>
Wed Apr 28 15:49:26 CEST 2010



>>> to_a_or_to_ab_or_to_none(A, B) ->
>>>     A ! foo,
>>>     B ! bar,
>>>     crash().

On Wed, 28 Apr 2010 14:09:38 +0200, Dmitry Belyaev <>  
wrote:

> Maybe I was too hurry to answer.
>
> http://erlang.org/doc/reference_manual/processes.html#id2279644
> Message sending is asynchronous and safe, the message is guaranteed to
> eventually reach the recipient, provided that the recipient exists.

Yes, according to the Reference Manual, messages will arrive (provided  
that A and B exists). This is probably also true if A resides on the same  
node as the sender. However If the sender does not reside on the same node  
things are not that simple.

To start with we could have a temporary network problem causing the  
message foo to be lost (it is in the senders buffer until it gives up and  
throws the message away). The first send operation (as far as I know) does  
not wait for the foo message to be acknowledged and continues with sending  
bar to B.

Another problem is if the foo message is placed in the out buffer waiting  
to be sent and bar is placed in another out buffer. What if bar is sent  
and then the sender node crashes.

Maybe the reference manual should say: Message sending is asynchronous,  
the message is guaranteed to
  eventually reach the recipient, provided that the recipient exists and  
there is no problem.

Is this the proper description of send?

   Johan



-- 
Dr Johan Montelius
Royal Institute of Technology - KTH
School of Information and Communication Technology - ICT


More information about the erlang-questions mailing list