[erlang-questions] C nodes and select loops

Michael Truog mjtruog@REDACTED
Wed Nov 14 18:06:49 CET 2012

The main problem is handling the is calling the ei_receive (or one of the variations on this function) often enough so no node ticks are missed, such that you don't cause a nodesplit.  This is the ERL_TICK shown in http://www.erlang.org/doc/tutorial/cnode.html , mentioned here http://erlang.org/doc/man/ei_connect.html#ei_receive .  So, this provides a maximum time you have to process internal events, unless you create separate threads to do work internally, within your cnode.  You can always set the net ticktime to be longer, but I have found that to cause problems with links between nodes (due to assumptions that seemed to exist, which may not exist now).  If you are doing integration like this, consider looking at CloudI (http://cloudi.org), which helps to avoid cnode integration (cnode integration limits system scalability, because of the net ticktime).

On 11/14/2012 08:05 AM, David Welton wrote:
> Hi,
> I expected to find an answer to this one via Google, but I didn't.
> I'm looking at the C node example, and it does:
>     while (loop) {
>         got = erl_receive_msg(fd, buf, BUFSIZE, &emsg);
> Which is ok if you can sit around waiting on incoming Erlang messages,
> but say you want to work with a select loop (or whatever form of
> polling/events) where you can get events from other places, as well as
> from other Erlang nodes.
> The ei_connect man page says:
>        As with all other ei functions, you are not expected to put the  socket
>        in non blocking mode yourself in the program. Every use of non blocking
>        mode is embedded inside the timeout functions. The socket  will  always
>        be back in blocking mode after the operations are completed (regardless
>        of the result). To avoid problems, leave the socket options  alone.  Ei
>        will handle any socket options that need modification.
> That makes me a bit wary...  Granted, there are the _tmo options, but
> I just wanted to ask around for advice on best practices for something
> like this.
> Thanks
> --
> David N. Welton
> http://www.dedasys.com/
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list