|
Versions Of This Snippet::
Download a raw-text version of this code by clicking on "Download Version"
Latest Snippet Version: :1.1
#!/usr/bin/perl -w
# Autor: peter bauer
# peba@inode.at
use warnings;
use strict;
use IO::Socket;
my $index=0;
my $len=0;
my $res=0;
my $com = "";
my $port = 20000;
my $server = undef;
do {
$server = new IO::Socket::INET(
Proto => 'tcp',
LocalPort => $port,
Listen => 1,
);
unless (defined $server) {
print "Socket busy - retrying in 10 seconds\n";
sleep (10);
}
}
until (defined $server);
print "Server running on port $port...\n";
while (my $connection = $server->accept) {
#print "Client connected at ", scalar(localtime), "\n";
#print $connection "You're connected to the server!\n";
while (<$connection>) {
#print "Client says: $_";
$index=index($_,"/cgi-bin/message?");
if ($index > 1) {
$len=length($_)-32;
$res=substr $_,$index+17,$len;
#print $res."\n";
$com="./popup_tk.pl ".$res;
system $com;
}
$index=index($_,"Alive"); #end of tcp message reached
last if $index > 1; #end the loop end disconnect
}
close $connection;
#print "Client disconnected\n";
}
Submit a new versionYou can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..
|
||||||||||||||||||||||||||||||||||||
