Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for linux / perl experts

Status
Not open for further replies.

safra

Technical User
Joined
Jan 24, 2001
Messages
319
Location
NL
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

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 &quot;Existing socket $number{$sock} is pending: &quot; if ($verb > 3);
           chomp $buf;
           print &quot;$buf\n&quot; if ($verb > 3);
           ($data) = $buf =~ /data=&quot;(.*?)&quot;/;
           print $sock qq|<response data=&quot;You said '$data'&quot; />|;

#				foreach $client ($handles->handles) {
#        			print $client qq|<response data=&quot;client: $client - You said '$data'&quot; />|;
#        		}

        } else {
           print &quot;Socket $number{$sock} is gone.\n&quot; if ($verb > 2);
           $handles->remove($sock);
        }
     }
   }
}
 
Have you tried changing the LocalHost param to your external ip address? Perhaps the socket isn't failing but just isn't listening at the correct address.

jaa
 
Yes, I have tried every possible combination of host param settings both in the perl script as in the flash movie.

Thanks,
Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top