|Don't ask to ask, just ask|
Re^3: Best technique to code/decode binary data for inter-machine communication?by BrowserUk (Pope)
|on Aug 16, 2012 at 00:38 UTC||Need Help??|
That's good for packets up to 64k in length. Switch to 'N' to handle up to 4GB.
The nice thing about this is that the receiver always knows how much to ask for; and can verify that he got it (length $binData) which avoids the need for delimiters and works just as well with non-blocking sockets if you need to go that way.
Important update: If using this method to transmit data between machines, see also the thread at Mystery! Logical explanation or just Satan's work?
I also found that when it comes to transmitting arrays and hashes, using pack/unpack is usually more compact (and therefore faster) than using Storable, because (for example) an integer always required 4 or 8 bytes binary, but for many values it is shorter in ascii:
It doesn't always work out smaller, but it is usually faster and platform independent.
Of course, storable wins if your data structures can contain references to others.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.