[erlang-questions] erlang C node packets not being recognized

Guido Sohne <>
Sun Apr 22 16:58:52 CEST 2007


Hi,

I'm writing a Ruby extension to communicate with Erlang nodes using
distributed Erlang. I'm using erl_interface to cook up the packets and
I've managed to connect to a genuine Erlang node, except it doesn't
want to recognize the packets I'm sending.

This is the routine I'm using to send. It expects to be passed an
array from Ruby, and it sends that to the remote node. I've taken a
look at the source for it and it adds the version header and other
header information, then is supposed to append the payload, which is
the array we received from Ruby.

static VALUE
re_conn_reg_send(VALUE self, VALUE to, VALUE message)
{
  re_conn_t *conn;
  Data_Get_Struct(self, re_conn_t, conn);

  VALUE timeout = rb_iv_get(conn->config, "@timeout");

  void *s = RARRAY_PTR(message);
  int l = RARRAY_LEN(s);

  conn->buffer.index = 0;
  if(ei_reg_send_tmo(&conn->cnode, conn->fd, StringValueCStr(to), s,
l, NUM2INT(timeout)) == 0)
    return Qtrue;
  else {
    switch(erl_errno) {
      case EIO:
        printf("rsend: %d\n", erl_errno);
        rb_raise(rb_eIOError, "failed", NULL);
        return Qfalse;
      case ENOMEM:
        rb_raise(rb_eNoMemError, "out of memory", NULL);
        return Qfalse;
    }
  }
}

It doesn't work because the Erlang node doesn't believe that it is a
genuine packet.

=ERROR REPORT==== 22-Apr-2007::14:51:58 ===
Got invalid data on distribution channel, offending packet is:
<<112,131,104,4,97,6,103,100,0,17,105,110,115,105,103,104,116,64,49,50,55,46,48,46,48,46,49,0,0,0,3,0,0,0,0,1,100,0,0,100,0,4,116,101,115,116>>

I can't find any good information on the Erlang wire format for
packets, so I don't know how to work back from this error report to
what the C node is actually sending. I'm trying to base this solely on
the libei routines, not liberl_interface, since it appears that
erl_interface is only a wrapper for libei.

Thanks in advance!

-- G.



More information about the erlang-questions mailing list