Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: How to sent binary data in socket programming ?

by golux (Pilgrim)
on Jul 14, 2013 at 11:21 UTC ( #1044216=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to sent binary data in socket programming ?
in thread How to sent binary data in socket programming ?

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


Comment on Re^3: How to sent binary data in socket programming ?
Select or Download Code
Re^4: How to sent binary data in socket programming ?
by bh_perl (Monk) on Jul 15, 2013 at 01:34 UTC

    hi...

    That files contains data on mail first, anyway this is the records of the files:-
    4A 42 48 42 30 30 30 34 30 30 30 30 30 30 33 30 30 31 30 30 30 30 30 3 +0 30 30 30 38 39 36 33 32 30 30 20 20 20 20 20 20 20 20 20 20 20 20 2 +0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2 +0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2 +0 20 20 20 20 20 20 20 20 20 20 20 20 20 30 32 30 37 32 37 36 33 38 3 +0 30 20 30 32 20 20 20 20 20 20 20 20 20 20 20 20 20 20 31 33 30 37 3 +1 32 31 34 34 34 31 31 30 30 30 30 33 33 20 20 20 20 20 20 20 20 4A 4 +2 48 42 30 30 31 34 30 30 30 30 30 30 32 30 30 39 30 30 30 30 30 30 3 +0 30 30 35 32 30 37 34 34 35 20 20 20 20 20 20 20 20 20 20 20 20 20 2 +0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2 +0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2 +0 20 20 20 20 20 20 20 20 20 20 20 20 39 39 00 00 00 00 00 00 00 00 0 +0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0 +0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0 +0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <br/> <br>This is the result after i run the script<br/> <code> DATA : 4A4248423030303430303030303033303031303030303030303030383936333 +230302020202020202020202020202020202020202020202020202020202020202020 +202020202020202020202020202020202020202020202020202020202020202020202 +020202020203032303732373633383030203032202020202020202020202020202031 +333037313231343434313130303030333320202020202020204A42484230303134303 +030303030323030393030303030303030303532303734343520202020202020202020 +202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202039390000000000 +000000000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000 +00 ASCII: JBHB000400000030010000000008963200 + 02072763800 02 + 130712144411000033 JBHB001400000020090000000005207445 + 99  Connected to server [19.25.15.22] with port 1998 Sent binary data as request to 19.25.15.22 [length 344] Message from Server :

    Based on the result, the recv() did not display anything. Why this is happened ? is it I am wrong ?. For your information, my connection using TCP/IP and connected to cisco router, is it different with UDP ?

    I am trace the data packet using nettl command for hpux server.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1044216]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2014-10-02 17:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (67 votes), past polls