Problem in erlang interface

Robert Raschke rrerlang@REDACTED
Tue Mar 8 14:59:43 CET 2005


maruthavanan_s@REDACTED writes:
> I want to establish communication between C node and Erlang node, for that 
> I'm using ei_connect_init() function and ei_connect. There is no [problem in 
> establishing connection between two processes but when I tried to receive 
> message from C node using the library function ei_receive_msg(), the 
> function fails with value ERL_EXIT.

One of the problems I came across trying to run a C node (I now use
the port mechanism and a C program that communicates via stdin/out) is
nicely captured in a comment in some old code of mine:

main_message_loop(int fd, char *mynodeid)

	/* This loop can be very problematic if the handle_message()
	function takes a long time. Erlang expects to get answers to
	ERL_TICK messages in order to keep the connection alive. If an
	operation dealt with by handle_regular_message() takes a long time,
	then these tick will not get answered, leading Erlang to think this
	C node has died. */

	while (ok) {
		result = ei_xreceive_msg(fd, &msg, &x_in);
		switch (result) {
		case ERL_TICK:
		case ERL_MSG:
			switch (msg.msgtype) {
			case ERL_EXIT:
				ok = 0;
			case ERL_SEND:
			case ERL_REG_SEND:
				ei_send(.....); /* return results */

Could it be that the Erlang side thinks your node has died?  In that
case you may have to look into threading to help you deal with long
running commands.


More information about the erlang-questions mailing list