Hi bh_perl,

First, how can we know what the result of the following is? ...

my $dir = "/data/input"; my $data = `cat $dir/cdr-data.dat |sed 's/ //g'`; my $binary = pack ("H*", $data);

That's a file on your system, which we have no access to.

You also haven't said anything about the results you get back, which makes it impossible to know how it's failing for you.

Do you have access to the server-side code? If so, try logging to a local file what's happening on the server side. Make sure you log each step, so if something fails you'll know exactly where in the code it happened.

If you look at the documentation for recv it suggests perusing "UDP: Message Passing" in perlipc for examples, and referring to that section of the perlipc docs shows an example of recv where the error is displayed:

$hispaddr = recv(SOCKET, $rtime, 4, 0) || die "recv: $!";

What happens if you do the same in your code?, ie.:

$socket->recv($response, 1024); defined($response) || die "recv: $!";

Update: looking closer at recv shows that it may be the return value from $socket->recv(...) that you want to check for undef, ie:
$socket->recv($response, 1024) || die "recv: $!";

say  substr+lc crypt(qw $i3 SI$),4,5

In reply to Re^3: How to sent binary data in socket programming ? by golux
in thread How to sent binary data in socket programming ? by bh_perl

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.