[erlang-questions] C nodes and select loops

David Welton davidw@REDACTED
Wed Nov 14 17:05:48 CET 2012


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.

David N. Welton


More information about the erlang-questions mailing list