[erlang-questions] Two confusions??

Ish Rattan ishwar@REDACTED
Thu Feb 11 18:20:57 CET 2010

On Thu, 11 Feb 2010, Robert Virding wrote:

> On 10 February 2010 18:08, Ish Rattan <ishwar@REDACTED> wrote:
>> ...
>> 2. A C-client sends 4-byte int request (with numeric
>>   value N encoded in the 4-bytes), erlang server
>>   receives the request (in binary) and prints as:
>>   <<0, 0, 0, N>>
>> what is the interpretation here?
> The 4 bytes in the binary are the 4 byte int request sent by the
> client. Socket data is received as a binary containing the bytes sent
> over the socket (or alternatively as a list of bytes). It is up to the
> receiver to interpret those bytes, for example as ASCII characters or
> UTF-8 encoded Unicode characters or ... . In this case the 4 bytes are
> a big endian integer. A simple way to extract them is to match against
> the input binary with the pattern <<Request:32>> which does this.
> Is this what you meant?
Thanks for the answer:
  now the server (computes factorial of N) and wants to send the reply
how will the be marshalled for client (expects a 4-byte answer when 
overflow is not an issue).

For me, picture is clean when both server and client are in Erlang
because of agreement on {packe, 1|2|4} part, but becomes fuzzy when one of 
them is in Erlang.


More information about the erlang-questions mailing list