bear0053 has asked for the wisdom of the Perl Monks concerning the following question:
sub send_to_processor{ my $message = $_[0]; use Sys::Hostname; use Socket; my @transaction_ips = ('10.30', '10.31'); #If connection isn't open, then open it for(my $i = 0;$i < 4;$i++){ last if($remote = IO::Socket::INET->new(Proto => 'tcp', PeerAd +dr => $transaction_ips[($i%2)], PeerPort => 8120, Timeout => 5)); } #If connection still isn't open, #then connection is unavailable unless(defined $remote){ return(0, 'Server Unavailable!'); } #Send Message print $remote $message; #Recieve Response my $response; recv($remote, $response, 2048, 0); #Close Connection close $remote; return (1,$response); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: flip-flop socket locations if 1 is down
by monkey_boy (Priest) on Jun 09, 2005 at 16:51 UTC | |
by bear0053 (Hermit) on Jun 09, 2005 at 22:46 UTC |