Hi Everyone <div><br></div><div>So the instructions for writing a c-node here <a href="http://www.erlang.org/doc/tutorial/cnode.html">http://www.erlang.org/doc/tutorial/cnode.html</a> , although still working are way out of date ( they don't use the newer ei_connect <a href="http://www.erlang.org/doc/man/ei_connect.html">http://www.erlang.org/doc/man/ei_connect.html</a> )</div>
<div><br></div><div>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.</div>
<div><br></div><div>As far as i can tell i can successfully connect to a running Erlang node ( "e1@localhost" ) like so :</div><div><br></div><div><div>ei_cnode ec;</div><div><br></div><div>if (ei_connect_init(&ec, "e1", "secretcookie", n++) < 0)</div>
<div>{</div><div> printf("error!");</div><div>}</div><div>else</div><div>{</div><div> printf("connected!");</div><div>}</div><div><br></div><div>int fd = ei_connect(&ec, "e1@localhost");</div>
<div>if(fd<1)</div><div>{</div><div> printf("ei_connect error : %d",fd);</div><div> return;</div><div>}</div></div><div><br></div><div>seems to work fine, and defiantly fails if i get the cookie wrong etc..</div>
<div><br></div><div>what does not work tho is trying to receive a message :</div><div><br></div><div><div><div>ei_x_buff x;</div><div>ei_x_new(&x);</div><div><br></div><div><br></div><div>if (ei_xreceive_msg(fd, &msg, &x) > 0)</div>
<div>{</div><div> // do something </div><div>}</div><div>else{printf("failed");}</div><div><br></div></div></div><div><br></div><div><br></div><div>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 </div>
<div><br></div><div>is there something simple i am doing wrong ?</div><div><br></div><div>James</div>