while (<$first>)
{
my $name = $_;
chomp($name);
#send acknowledgement message to First
print "Received from [$f_host $f_port]: $name\n";
#print $f_socket "$.: $name\n";
#Sending info upstream to Third process
#this part works fine
if($name eq $match)
{
print "Second found match: $name\n";
print "Second sending \"$name\" to Third\n";
print $t_socket "$match\n";
}
#after I send I am expecting a response
#from Third process
#I never get into this loop
#it skips or accept() blocks indefinitely
while(my $third = $t_socket->accept)
{
print "Second has accepted socket to Third...\n";
my $t_host = gethostbyaddr($third->peeraddr, AF_INET);
my $t_port = $third->peerport;
while (<$third>)
{
my $name = $_;
chomp($name);
print "Received from [$f_host $f_port]: $name\n";
if($name eq $match)
{
print "Received \"$name\" from Third\n";
last;
}
else
{
last;
}
}
}
}
####
if($name eq $match)
{
print "Third sending \"$name\" to Second\n";
print $socket "$name\n";
#close $second or die "Can't close ($!)\n";
last;
}
####
my $socket = IO::Socket::INET->new('LocalPort' => $PORT,
'Proto' => 'tcp',
'Listen' => 2)
or die "Second: Can't create socket to First($!)\n";
#VERSUS
my $socket = IO::Socket::INET->
new( 'PeerAddr' => "localhost",
'PeerPort' => $PORT,
'Proto' => 'tcp')
or die "Second: Can't create socket to Third($!)\n";
####
while(my $handle = $socket->accept)
{
while(<$handle>)
{
#do something with $_
}
}