[erlang-questions] cannot send messages to a C-node

Roberto Ostinelli <>
Fri Apr 24 17:52:00 CEST 2009


i haven't tried that, will take a look at it.

thank you,

r.


On 24/apr/09, at 17:39, Pablo Polvorin wrote:

> Have you tried the ei_* API instead?,
> (http://erlang.org/doc/apps/erl_interface/index.html)
> ei has a number of advantages,  I think it is the preferred way to
> write c code,
>
>
>
> 2009/4/24 robbie13 <>:
>>
>> hi all,
>>
>> i cannot find a way to send messages to an erlang c-node. i create  
>> the
>> c-node with the following:
>>
>> ------------------------------------------
>> struct in_addr addr;
>> addr.s_addr = inet_addr("127.0.0.1");
>> if (erl_connect_xinit("rob.loc", "http_cnode",  
>> "", &addr,
>> "secretcookie", 0) == -1)
>>        erl_err_quit("erl_connect_xinit");
>> if (erl_connect("") == -1)
>>        erl_err_quit("erl_connect");
>> ------------------------------------------
>> rob.loc is configured in my /etc/hosts file to point to 127.0.0.1.
>>
>> i do get connected, and as i can see from my  erlang  
>> shell:
>> ------------------------------------------
>> ()21> nodes(hidden).
>> ['']
>> ------------------------------------------
>>
>> the code i have to receive messages is the typical:
>> ------------------------------------------
>> unsigned char buf[BUFSIZE];              /* Buffer for incoming  
>> message */
>> ErlMessage emsg;                         /* Incoming message */
>>
>> while (1) {
>>        fprintf(stderr, "start\n\r");
>>        got = erl_receive_msg(fd, buf, BUFSIZE, &emsg);
>>        fprintf(stderr, "GOT MESSAGE\n\r");
>>        if (got == ERL_TICK) {
>>                continue;
>>        ...
>> ------------------------------------------
>>
>> if i send a message to the node:
>> ------------------------------------------
>> ()22> {any, } ! {test, "hello!"}.
>> {test, "hello!"}
>> ------------------------------------------
>> the code of the c-node never gets to the GOT MESSAGE printout.
>>
>> instead, if i initialize the c-node with:
>> ------------------------------------------
>> if (erl_connect_init(1, "secretcookie", 0) == -1)
>>        erl_err_quit("erl_connect_init");
>> if ((fd = erl_connect("")) < 0)
>>        erl_err_quit("erl_connect");
>> ------------------------------------------
>> everything works correctly, but i cannot specify an hostname for  
>> the c-node.
>>
>> any kind soul would have a clue to this? thank you in advance..
>>
>> r.
>> --
>> View this message in context: http://www.nabble.com/cannot-send-messages-to-a-C-node-tp23218139p23218139.html
>> Sent from the Erlang Questions mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>




More information about the erlang-questions mailing list