[erlang-questions] port_command and marshalling

Paul Oliver puzza007@REDACTED
Mon Oct 29 21:37:43 CET 2007


Thanks Per!  That did the trick.

On 10/29/07, Per Hedeland <per@REDACTED> wrote:
> "Paul Oliver" <puzza007@REDACTED> wrotes:
> >
> >I have a port open with opts [{packet, 4}, binary] and call it using:
> >
> >port_command(Port, term_to_binary(Msg)),
> >
> >With the definition of  receive_erlang_port_msg below, for a
> >particular call, I get:
> >
> >lengthstr[0]=0
> >lengthstr[1]=0
> >lengthstr[2]=5
> >lengthstr[3]=-103
> >LEN=-103
> >
> >Does anyone know where the -103 comes from?
>
> It comes from 153 + your use of an apparently-signed type 'byte' for the
> length bytes. If you switch that to 'unsigned char' it will work (at
> least upto len = 2^31-1). Or cast the bytes to 'unsigned char' instead
> of 'unsigned' (which isn't some "generic" thing, but just short for
> 'unsigned int').
>
> --Per Hedeland
>


-- 
http://mosangeles.net



More information about the erlang-questions mailing list