[erlang-questions] up-to-date c node not working

James Churchman jameschurchman@REDACTED
Thu Jun 7 01:55:10 CEST 2012


Ok worked it out... the docs at
http://www.erlang.org/doc/man/ei_connect.html use the same name
"madonna" for both the initialisation and the connection .. but the
initialisation is for the c-node name and the connection needs the
name of the erlang node to connect to... tad confusing that the docs
use the same name.. but now it does work ..

James

On 6 June 2012 23:40, James Churchman <jameschurchman@REDACTED> wrote:
> Hi Everyone
>
> So the instructions for writing a c-node here
> http://www.erlang.org/doc/tutorial/cnode.html , although still working are
> way out of date ( they don't use the
> newer ei_connect http://www.erlang.org/doc/man/ei_connect.html )
>
> I can get the older example code working well but can't however get the
> newer ones going .. doing some google-ing it seems people as far back as
> 2005 have the same issue but nowhere can i find a fix.
>
> As far as i can tell i can successfully connect to a running Erlang node (
> "e1@REDACTED" ) like so :
>
> ei_cnode ec;
>
> if (ei_connect_init(&ec, "e1", "secretcookie", n++) < 0)
> {
>     printf("error!");
> }
> else
> {
>     printf("connected!");
> }
>
> int fd = ei_connect(&ec, "e1@REDACTED");
> if(fd<1)
> {
>     printf("ei_connect error : %d",fd);
>     return;
> }
>
> seems to work fine, and defiantly fails if i get the cookie wrong etc..
>
> what does not work tho is trying to receive a message :
>
> ei_x_buff x;
> ei_x_new(&x);
>
>
> if (ei_xreceive_msg(fd, &msg, &x) > 0)
> {
>     // do something
> }
> else{printf("failed");}
>
>
>
> what ever i try ei_xreceive_msg returns -1 .. if it's in a loop (as similar
> code found on the net) it will loop non stop and consume 95 % cpu time
>
> is there something simple i am doing wrong ?
>
> James



More information about the erlang-questions mailing list