Trouble with ei...

WILLIAMS Dominic D.WILLIAMS@REDACTED
Thu Dec 4 09:47:33 CET 2003


Hello,

I am trying to connect to an Erlang node from a C program, using ei.

I wrote a simple server:

-module(server).
-export([start/0,loop/0]).

start() ->
	register(spike,spawn(server,loop,[])).

loop() ->
	receive
		quit ->
			bye;
		Other ->
			io:format("~p~n",[Other]),
			loop()
	end.

Which works when called from another erlang node.
However, the following C program exits without errors, but nothing appears on the server's output...

#include "erl_interface.h"
#include "ei.h"

int main()
{
    ei_cnode ec;
    ei_connect_init(&ec, "pcwilliams", "vaccin", 1);
    int fd = ei_connect(&ec, "node2@REDACTED");
    if (fd < 0) erl_err_quit("connect failed");
    ei_x_buff x;
    ei_x_new_with_version(&x);
    ei_x_encode_atom(&x, "hello_from_c");
    int res = ei_reg_send(&ec, fd, "spike", x.buff, x.index);
    if (res < 0) erl_err_quit("send failed");
    ei_x_free(&x);
    return 0;
}

My configuration is W2K, R9C.
I tried long and short node names, to no avail.
When I use a bad cookie, the server reports an attempted connection from unauthorized node, and the C program exits with an error. So the program seems to be connecting to the Erlang node, but the message is not getting through to the server.

Any suggestions?

Thanks,

Dominic Williams.



More information about the erlang-questions mailing list