<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:Arial,Helvetica,sans-serif">On Mon, Jan 4, 2021 at 3:40 PM George Hope <<a href="mailto:george@1w1g.com">george@1w1g.com</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u><div><div style="font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif"><div id="gmail-m_-2247645119908469305message"></div>By synchronous I mean if the program does not finish processing processing of first packet and packet 2,3 arrived does Erlang VM wait for handle_info to return? <div>Is it possible to lose sequnce of packets?<br><div></div></div></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Yes, it will wait. Packets that arrive are placed in the process mailbox. The gen_server main event loop will look into the mailbox and if it isn't one of the "specially tagged" messages that invokes a handle_cast or handle_call, it is passed to handle_info for processing, one at a time. You are guaranteed that other messages will arrive in the mailbox, subject to the Erlang message ordering guarantees.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif"><div><div>As far as I know handle_call is sync and handle_cast is async in gen_server.<br id="gmail-m_-2247645119908469305br3"><br id="gmail-m_-2247645119908469305br3"></div></div></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Ah! In this case, this pertains to a client's view if it calls a gen_server.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">When you cast to a server, you send a message into the mailbox, and you don't wait as a client. The server will eventually get to the message in the mailbox and process it through handle_cast.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">When you call a server, your client blocks until it receives a reply or times out. The server will eventually get to the message in the mailbox and process it through handle_call. If handle_call replies, the client is unblocked.</div></div><div><br></div><div><br></div></div></div>