Order Tray | Contact Us | Home | SIG Lists

[aprssig] Perl socket programming

Andrew Rich vk4tec at people.net.au
Thu Apr 10 14:04:27 UTC 2008


And what I don't get is

print $sock 
chr(34),chr(0),chr(16),chr(244),chr(4),chr(27),chr(2),chr(10),chr(169),chr(180),chr(224),chr(148),chr(4),chr(32),chr(40),chr(0);

Sends one UDP packet with 16 bytes,

while

$data = "34 0 16 244 4 27 2 10 169 180 224 148 4 32 40 0";
@array = split(" ",$data);
foreach $val (@array)
{
print $sock chr($val);
print $val."\n";
}
sleep 1;
close $sock;

Sends 16 UDP packets, 1 byte each.



----- Original Message ----- 
From: "Rich Mulvey" <aprs at mulveyfamily.com>
To: "TAPR APRS Mailing List" <aprssig at lists.tapr.org>
Sent: Thursday, April 10, 2008 11:14 PM
Subject: Re: [aprssig] Perl socket programming


> Andrew Rich wrote:
>> Any one good at socket programming ?
>>  I am trying to UDP some hex characters.
>>  Something so simple is turning out to be hard to find.
>>  Here is how to do it as a string, I just want to send hex instead
>>  #!/usr/bin/perl -w
>> # clientIO.pl - a simple client using
>> # IO::Socket
>> use strict;
>> use IO::Socket;
>> my $host = shift || 'localhost';
>> my $port = shift || 30003;
>> my $sock = new IO::Socket::INET(
>>                    PeerAddr => $host,
>>                    PeerPort => $port,
>>                    Proto    => 'udp');
>> $sock or die "no socket :$!";
>> foreach my $i (1..10) {
>>     print $sock "hello, world: $i\n";
>> sleep 1;
>> }
>> close $sock;
>
>
> print unpack( "H*", "Hello World $i" ) . "\n";
>
>
> Though I'm at a bit of a loss as to what this has to do with APRS...
>
>
> - Rich
>
>
>
> _______________________________________________
> aprssig mailing list
> aprssig at lists.tapr.org
> https://lists.tapr.org/cgi-bin/mailman/listinfo/aprssig
> 





More information about the aprssig mailing list