altobravo
asked on
Perl Sockets - Raw Data
I am using a modified sample script to capture udp packets on a single port and then send the data back to the sender. This seems to work fine. My issue is that the payload being sent seems to be converted to ascii. Anything that I have tried converts the data to ascii then back to hex, something gets lost in translation. What I need is the original message as it is sent. Thanks
Sample packet data
8305123100138201010102034c 4b28ead64b 28ead618a7 4dd4d42246 7a00003c4d 0000002101 170620001a ffab0f280f 0005030200 0000000000 00c594
Sample packet data
8305123100138201010102034c
#!/usr/bin/perl -w
# udpqotd - UDP message server
use strict;
use IO::Socket;
my($sock, $newmsg, $hisaddr, $MAXLEN, $PORTNO);
$MAXLEN = 1024;
$PORTNO = 21210;
$sock = IO::Socket::INET->new(LocalPort => $PORTNO, Proto => 'udp' )
or die "socket: $@";
print "Awaiting UDP messages on port $PORTNO\n";
while ($sock->recv($newmsg, $MAXLEN)) {
my($port, $ipaddr) = sockaddr_in($sock->peername);
print "This: $newmsg \n" ;
$sock->send($newmsg);
}
die "recv: $!";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.