[erlang-questions] Two confusions??
Robert Virding
rvirding@REDACTED
Thu Feb 11 17:09:42 CET 2010
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?
Robert
More information about the erlang-questions
mailing list