[aprssig] Perl socket programming

Gregg Wonderly gregg at wonderly.org
Thu Apr 10 12:02:31 EDT 2008


Andrew Rich wrote:
> 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.

Yes, because you are sending bytes to a socket object that is UDP bound, and 
that means it's not a stream, but rather a packet oriented operation.  Thus, 
each "thing" you send it with print, is going out in a UDP packet.

Gregg Wonderly




More information about the aprssig mailing list