[erlang-questions] Questions on C/Java nodes

Paul Guyot pguyot@REDACTED
Wed Oct 1 08:43:47 CEST 2008


Hello,

The tutorial for the C nodes (I'm pretty sure I've seen some similar  
code for Java nodes) goes like this:

listen(..., 5)
erl_publish(...)
fd = erl_accept(...)
while (true) {
	erl_receive_msg(fd, ...)
}

 From what I understand, the C node can only have one peer (the first  
one that connects). Yet, still in the tutorial sample code [1], listen 
(2) is called with a backlog of 5. Is there any reason why the  
tutorial code isn't a regular fork(2) or select(2)-based server code,  
except for simplicity (and that this probably wouldn't be portable on  
Windows)? On Unix, can select(2) be used on the file descriptor  
returned by erl_accept?

Still on the C nodes, I am confused by the creation parameter of  
erl_connect_init. The man page erl_connect(3) says:

> creation helps identify a particular instance of a C node. In
> particular, it can help prevent us from receiving messages sent
> to an earlier process with the same registered name.
>
> A C node acting as a server will be assigned a creation number
> when it calls erl_publish().


and then the sample code below gives 0. In which case should we  
provide something different from 0?

Paul

[1] http://erlang.org/doc/tutorial/cnode.html




More information about the erlang-questions mailing list