<div>Hello,</div><div><br></div><div>I try to send message from C code to erlang. I use EI Library.</div><div><br></div><div>My C code:</div><div><br></div><div> int main (int argc, char** argv)</div><div> {</div><div>
erl_init (NULL, 0);</div><div> </div><div> extern const char *erl_thisnodename(void);</div><div> extern short erl_thiscreation(void);</div><div> </div><div> #define SELF(fd) erl_mk_pid(erl_thisnodename(), fd, 0, erl_thiscreation())</div>
<div> </div><div> ETERM *arr[2], *emsg;</div><div> </div><div> int sockfd, creation=1;</div><div> </div><div> arr[0] = SELF(sockfd);</div><div> arr[1] = erl_mk_atom("ok");</div><div>
emsg = erl_mk_tuple(arr, 2);</div><div> </div><div> erl_reg_send(sockfd, "my_server", emsg);</div><div> erl_free_term(emsg);</div><div> </div><div> return (EXIT_SUCCESS);</div><div> }</div>
<div><br></div><div>And my erlang code:</div><div><br></div><div> start() -></div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>Pid = spawn(?MODULE, loop, []),</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>register(my_server, Pid).</div>
<div> </div><div> loop() -></div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>receive</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>{ok} -></div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>io:format("Ok received \n"),</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span>loop();</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>stop -></div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>stop;</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span>_ -></div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>io:format("Somethig else \n")</div><div> end.<span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div> </div><div> stop() -></div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>my_server ! stop.</div><div><br></div><div>But when i run my C application, erlang application nothing received. What's wrong?</div>
<div><br></div><div>Thank you.</div><div><br></div>