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

James Churchman <>
Thu Jun 7 00:40:12 CEST 2012


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 (
"" ) like so :

ei_cnode ec;

if (ei_connect_init(&ec, "e1", "secretcookie", n++) < 0)
{
    printf("error!");
}
else
{
    printf("connected!");
}

int fd = ei_connect(&ec, "");
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120606/61d84c8f/attachment.html>


More information about the erlang-questions mailing list