in reply to Re^2: How to sent binary data in socket programming ?
in thread How to sent binary data in socket programming ?
First, how can we know what the result of the following is? ...
That's a file on your system, which we have no access to.
my $dir = "/data/input";
my $data = `cat $dir/cdr-data.dat |sed 's/ //g'`;
my $binary = pack ("H*", $data);
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.:
Update: looking closer at recv shows that it may be the return value from $socket->recv(...) that you want to check for undef, ie:
defined($response) || die "recv: $!";
$socket->recv($response, 1024) || die "recv: $!";
substr+lc crypt(qw $i3 SI$),4,5