Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

BrowserUk,

First I'm interested in the code sample you gave:

$to->send( pack 'n/a*', $binData );
Currently I write that as:
$binData = pack('N',length( $data ) ) . $data; $to->send( $binData );
Is your code a shorthand for the above?

Second, as you and others have pointed out, I did not use 'binmode' after opening the socket. If I were to add the following:

binmode Socket, ":raw";
To both the client and server code, would I be in 'binary' mode on windows, *nix, etc. or would I need to have different client code for each. Reading the latest 'binmode' documentation, it sounds like the function would be ignored on some systems and then used where binary and text definitions differ.

Third, 'Storable' does not produce 'network neutral' results, so can't be used in this case.

Fourth, if someone passes a ':utf8' key/value pair to my application and I store the variables in an external file as ":raw", will they be able to use the data as utf8 when they receive the key/value pair back. Until I read the 'binmode' documentation, I didn't think of that possibility!

Thank you

"Well done is better than well said." - Benjamin Franklin


In reply to Re^4: Best technique to code/decode binary data for inter-machine communication? by flexvault
in thread Best technique to code/decode binary data for inter-machine communication? by flexvault

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    Discipulus has decided to use old english because of 'thou'..
    [erix]: hm, apparently almshouses are still around
    [Discipulus]: yes poor's workhouse, what they had more than their souls and some bone?
    [LanX]: erix alms = Almosen
    [erix]: yeah, Aalmoes (Niederlaendisch)
    [erix]: italian alma may be unrelated
    [choroba]: Alma in Hungarian is apple
    [choroba]: Alma
    [erix]: "may I eat your soul?"
    [LanX]: hey I was told yesterday that "Alma Ata" means father of the apple (ex capital of Kazakhstan) ... so alma is Turkish

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (12)
    As of 2017-11-23 20:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:













      Results (338 votes). Check out past polls.

      Notices?