From jan@swi.psy.uva.nl Fri Dec 14 17:29:54 2001
Received: from gollem.swi.psy.uva.nl (root@gollem.swi.psy.uva.nl [145.18.152.30])
	by swi.psy.uva.nl (8.11.6/8.11.2) with ESMTP id fBEGTs526432;
	Fri, 14 Dec 2001 17:29:54 +0100 (MET)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.3/8.11.3/SuSE Linux 8.11.1-0.5) id fBEGTrg30724;
	Fri, 14 Dec 2001 17:29:53 +0100
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: deloor <deloor@enib.fr>, prolog@swi.psy.uva.nl
Subject: Re: [SWIPL] little indian and socket
Date: Fri, 14 Dec 2001 17:24:58 +0100
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
References: <3C1A1F09.425E968@enib.fr>
In-Reply-To: <3C1A1F09.425E968@enib.fr>
MIME-Version: 1.0
Message-Id: <01121417295302.21872@gollem>
Content-Transfer-Encoding: 8bit

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

