[erlang-questions] Sending Message to Erlang node from C node

J Bhanot <>
Mon Feb 4 14:10:06 CET 2008


Hi,

I have succesfully connected to Erlang node from C node as when I execute 
following

nodes(hidden).

from Erlang node...i get the name of c node as 


Now when I am trying to send the message from C node to Erlang node using 
:

if(erl_reg_send(sockfd, "", cmsg) == 0)
{
printf("inside");
erl_err_sys("erl_reg_send");
   }

printf("outside");

I get neither inside nor outside...

the prompt just comes to next line

looks like process is dying while using erl_reg_send


On the erlang side, I am using following pong script:

-module(tut17).

-export([start_ping/1, start_pong/0,  ping/2, pong/0]).

ping(0, Pong_Node) ->
    {pong, Pong_Node} ! finished,
    io:format("ping finished~n", []);

ping(N, Pong_Node) ->
    {pong, Pong_Node} ! {ping, self()},
    receive
        pong ->
            io:format("Ping received pong~n", [])
    end,
    ping(N - 1, Pong_Node).

pong() ->
    receive
        finished ->
            io:format("Pong finished~n", []);
        {ping, Ping_PID} ->
            io:format("Pong received ping~n", []),
            Ping_PID ! pong,
            pong()
    end.

start_pong() ->
    register(pong, spawn(tut17, pong, [])).

start_ping(Pong_Node) ->
    spawn(tut17, ping, [3, Pong_Node]).

and after the executing following in Erlang shell :

tut17:start_pong().

I assume that my server process is registered and listening to messages - 
please correct me if ny understanding is not correct or anythingelse needs 
to be done.....

Please note :  I am able to connect but not able to send message from C 
node to Erlang node3

Appreciate your help..

Thanks and Regards,

jb____________________________________________

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080204/62e3002b/attachment.html>


More information about the erlang-questions mailing list