Newsgroups: comp.parallel.pvm
From: Roberto Hortal <rhortal@nefer.abo.fi>
Subject: Re: HELP: Packing/Unpacking
Organization: Abo Akademi University
Date: Fri, 23 Aug 1996 09:50:08 +0300
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT
Message-ID: <Pine.SOL.3.91.960823094524.1192A-100000@nefer.abo.fi>

On 19 Aug 1996, N. Munkman wrote:

> 
> I would like to implement a class member function to pack the class data into a
> buffer for transmission and another one to unpack it when it arrives. As the
> class is of a variable size (containg dynamically defined arrays) I would like
> to be able to indicate in some way (preferably within the packet) the size of the
> arrays. Is this possible (and if so how?) or would it have to be sent as two
> packets (i.e. One containing the size and the next the data)?
> 
> ------
> Neil Munkman			<n.s.munkman@ncl.ac.uk>
> 				[http://www.cs.ncl.ac.uk/people/n.s.munkman]
> 
> 
This is easily implementable if you don't need peak speed. The only thing 
to do is, in the packing function, calculate in advance the number and 
size of the arrays and pack those data as integers in the beginning of 
the packet. Then pack the arrays. Remember that a PVM message can hold 
mixed data types.
This has to be done like this, because if you calculate as you pack, the 
size data would be the last in the message, and PVM messages have to be 
unpacked in the same order that they where packed, thus making unusable 
the integers if not packed at the beginning of the array.
The unpacking function just unpacks the size data and uses it when 
unpacking the actual class.
Another trick: if the number of integers containing information is not 
fixed, you can use the label to indicate how many do you have in each 
message, as an absolute number or adding it to a base number, thus 
reserving tags below that base number for other uses.

Hope this helps.

		Roberto

    _I_           		MADE     IN     SPAIN
  _I)___I_      
  )_)__)__)        Laboratory Engineer. bo Akademi. Turku. Finland.
 \)_)__)__) \   
 _\I I )I\)_--  
 |________/       ----------------------------------------------------
+-+-+-+-+-+-+-+   "Es mentira que sepan a vinagre los besos sin amor".
			                                  J. Sabina.
                  ---------------------------------------------------- 
Roberto Hortal Muoz.   rhortal@abo.fi | http://www.abo.fi/~rhortal/


