File: subscribe.pl

package info (click to toggle)
uwsgi 2.0.29-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,684 kB
  • sloc: ansic: 87,027; python: 7,001; cpp: 1,131; java: 708; perl: 678; sh: 585; ruby: 555; makefile: 148; xml: 130; cs: 121; objc: 37; php: 28; erlang: 20; javascript: 11
file content (20 lines) | stat: -rw-r--r-- 445 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl

use IO::Socket::INET;

my %items = {};

$items{'key'} = $ARGV[1];
$items{'address'} = $ARGV[2];

my $uwsgi_pkt = '';

foreach(keys %items) {
	$uwsgi_pkt .= pack('v', length($_)).$_.pack('v', length($items{$_})).$items{$_};	
}

my $udp = new IO::Socket::INET(PeerAddr => $ARGV[0], Proto => 'udp');

$udp->send(pack('CvC', 224, length($uwsgi_pkt), 0).$uwsgi_pkt);

print ''.(length($uwsgi_pkt)+4).' bytes sent to '.$ARGV[0]."\n";