Subject: Re: [SWIPL] little indian and socket

From: Jan Wielemaker <[email-masked]>
Date: Fri, 14 Dec 2001 17:24:58 +0100

On Fri, 14 Dec 2001, deloor wrote:
>
>Hy
>
>I use the socket library and i want to send message with this format :
>
>- 32 bits --> size of the message in little indian format
>- ASCII characters (prolog atom) --> the heart of the message
>
>I use the write/2 predicat for the ASCII part but i don't know how to
>generate the head of my messages.
>
>is there anyone which could help me.

Just use Prolog bit-operations (>> and /\) to split the integer
into 4 bytes and then use put_byte/2 to write them in the
desired order to the socket.  For example,
getting the high byte can be written as:

	HighByte is (Value>>24) /\ 0xff.

	--- Jan