C interface example

Torbjorn Tornkvist tobbe@REDACTED
Wed Oct 6 23:45:59 CEST 1999


> I haven't figured out yet how to get the Erlang/OTP node
> to connect to a listening C node.  Can anyone give us a
> hand with that?

If I remember correctly you create a socket, bind an address
to it, and then tells epmd about it with erl_publish(PortNo).
You then listen to the socket (e.g using select). To connect
from Erlang just send a message, e.g: {hello,foo@REDACTED} ! 42
Your select should now release so you can do an erl_accept(SockFd)
and you'll receive the message '42' sent to the "registered process"
'hello' on you node ('foo@REDACTED'). NB: You have to send to a
{RegProc,Node} address since you can't create a valid pid from
within Erlang. However, if you connect from C to Erlang you
can create and send valid pids from C that can be used from 
Erlang (using erl_mk_pid() ).

It was a long time since I tried this so it may note be
fully correct. Let us know when you get it to work, and
perhaps add a FAQ entry at wikie.vegetable.org 

Cheers /Tobbe



More information about the erlang-questions mailing list