Hi,
I am trying to get a perl / flash xml socket app to work on a Red Hat 7.3 machine.
What happens is that everything works when I access the flash/html page through localhost ( When I access the page through my systems ip ( the flash movie loads correctly but the connection with the perl socket server fails. Actually it doesn't even return the message that no connection with the socket server could be made, it returns nothing at all.
Initially I thought this could be a security issue. For the last week or so I have been trying to fix this, with the help of others, but so far no success.
As this might be perl related I though perhaps one of you guys knows what could be the problem.
Underneath is a stripped version of the perl file which is running in the background.
Thanks,
Ron
I am trying to get a perl / flash xml socket app to work on a Red Hat 7.3 machine.
What happens is that everything works when I access the flash/html page through localhost ( When I access the page through my systems ip ( the flash movie loads correctly but the connection with the perl socket server fails. Actually it doesn't even return the message that no connection with the socket server could be made, it returns nothing at all.
Initially I thought this could be a security issue. For the last week or so I have been trying to fix this, with the help of others, but so far no success.
As this might be perl related I though perhaps one of you guys knows what could be the problem.
Underneath is a stripped version of the perl file which is running in the background.
Thanks,
Ron
Code:
#!/usr/bin/perl
use IO::Socket::INET;
use IO::Select;
$verb = 5; # verbosity for console messages
$main = new IO::Socket::INET (LocalHost => 'localhost',
LocalPort => 9000,
Listen => 5,
Proto => 'tcp',
Reuse => 1 ) || die $!;
$zero = chr(0);
$/ = $zero;
$\ = $zero;
$| = 1;
# Initialise IO::Select ------------------------------------------------
$handles = new IO::Select();
$handles->add($main);
print "Starting listening cycle\n" if ($verb > 1);
LISTEN: while (1) {
($pending) = IO::Select->select($handles, undef, undef, 60);
foreach $sock (@$pending) {
if ($sock == $main) {
$num++;
print "Got new connection: $num from ".$sock->sockhost()."\n" if ($verb > 2);
my $newsock = $sock->accept();
$newsock->autoflush();
$number{$newsock} = $num;
$handles->add($newsock);
} else {
my $buf = <$sock>;
if ($buf) {
print "Existing socket $number{$sock} is pending: " if ($verb > 3);
chomp $buf;
print "$buf\n" if ($verb > 3);
($data) = $buf =~ /data="(.*?)"/;
print $sock qq|<response data="You said '$data'" />|;
# foreach $client ($handles->handles) {
# print $client qq|<response data="client: $client - You said '$data'" />|;
# }
} else {
print "Socket $number{$sock} is gone.\n" if ($verb > 2);
$handles->remove($sock);
}
}
}
}