Re: Send a RealArray over a Socket
Matthew Fluet <[email protected]> Thu, 16 Aug 2007 08:07:40 -0500 (CDT)
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 16 Aug 2007, Gergely Buday wrote: >> I am trying to send a RealArray over a socket. >> However, I noticed that the sendArray function works >> only with Word8Arrays. What is the best way to send a >> large RealArray efficiently over a socket? >> >> Do I have to convert the RealArray into a Word8Array? > > Dear Vaishali, > > as John wrote you have to have a Word8Array to send it over a socket. > But an option would be to write a wrapper structure around Word8Array > that implements a part of RealArray's signature. It's not clear what > do you use to compute the RealArray but in an optimist's view it's > enough to implement sub, update and tabulate. And a simple function > that exports the underlying Word8Array that you will use only to send > it over a socket. What do you think of this? The structures that match the PACK_REAL signature are provided by the Basis Library as a convenient way of packing real values into a Word8Array: http://www.standardml.org/Basis/pack-float.html As Gergely suggests, if you can organize your computation so that you write the elements of the "final RealArray" directly into a Word8Array via PackRealLittle.update, then you won't have any additional copying. -Matthew ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/