Hi Monks,

I have the following piece of code that acts as a listing server for data.

The data is Binary data, but for some reason its displaying in ASCII, is it possible to write the data in its raw format to a file, or display it on the screen?
Or is it possible to convert this data to HEX format?
#!/usr/bin/perl -w use strict; use IO::Socket; my( $sock, $r_msg, $in_msg, $inhost, $MAXLEN, $PORTNO ); $MAXLEN = 10240; $PORTNO = 7780; $sock = IO::Socket::INET->new( LocalPort => $PORTNO, Proto => 'udp' ) or die "socket: $@"; print "Awaiting UDP messages on port $PORTNO\n"; $r_msg = "Received OK."; while ($sock->recv($in_msg, $MAXLEN)) { my($port, $ipaddr) = sockaddr_in($sock->peername); $inhost = gethostbyaddr($ipaddr, AF_INET); no utf8; print "Client $inhost said $in_msg\n"; # print sprintf("%04x",$in_msg)."\n"; use bytes; print length($in_msg)."\n"; $sock->send($r_msg); } die "recv: $!";
the above produces:
Client 41-208-48-1.xxxxxx.x.x said àêc':_è@âäçä-ó
50
Any help will be great

Kenny<br<

In reply to UDP Server Binary Data by xarex

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, details, 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, summary, 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.