[erlang-questions] Decoding Erlang Messages Sent Over TCP With EI
John Koenig
koenigjm@REDACTED
Sun Jan 2 22:04:57 CET 2011
I have just retried calling ei_decode_version before decode_tuple_header, and it returns -1.
Below is the output from gdb when I display the contents of the message buffer:
(gdb) p/x *msg@REDACTED
$3 = {0x70, 0x83, 0x68, 0x4, 0x61, 0x6, 0x67, 0x64, 0x0, 0xb, 0x65, 0x72, 0x6c, 0x79, 0x40, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x0, 0x3, 0x64, 0x0, 0x0, 0x64, 0x0, 0x3, 0x61, 0x6e, 0x79, 0x83, 0x68, 0x3, 0x64, 0x0, 0x6, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x30, 0x64, 0x0, 0x6, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x31, 0x6a}
(gdb) p *msg@REDACTED
$4 = "p�h\004a\006gd\000\verly@REDACTED\000\000\000%\000\000\000\000\003d\000\000d\000\003any�h\003d\000\006tuple0d\000\006tuple1j"
I can see portions of the original message in there...so at least I have that going for me... :S
John
On Jan 2, 2011, at 2:46 PM, Steve Vinoski wrote:
> On Sun, Jan 2, 2011 at 3:05 PM, John Koenig <koenigjm@REDACTED> wrote:
>> Code is attached.
>>
>> What you have said so far has brought me close of identifying the problem. Up until now I
>> have assumed that ei_decode_tuple_header would scan me ahead to the proper location, but I
>> starting to think I was wrong to do so. Especially after looking at the received data more
>> closely in gdb.
>>
>> How does one know the proper offset from which to start decoding the actual message?
>
> You start at offset 0 and the decode functions update the "index"
> variable you pass to them.
>
> Are you getting a version number on your message? You probably have to
> call ei_decode_version first to take the version number off the
> message. After that, I think the rest of your code will work.
>
> --steve
More information about the erlang-questions
mailing list