tjdmlhw has asked for the wisdom of the Perl Monks concerning the following question:
I was recently given the task of writing a perl script that would accept transactions from a MQSeries Queue and send them to a TCP/IP Socket. The socket had to remain connected for multiple sends through out the day because if the receiving system loses connectivity, user intervention is required to restart it.
The script was written and tested (see cut down version below), but I encountered a problem that I am having trouble getting around. If the receiving system loses connectivity and then is restarted, the perl script doesn't recognize that the connection is no longer there. The script sends the transaction without receiving an error message and goes back to get it's next transaction. The receiving system is waiting for the perl script to re-establish the connection. The script does fail on the second attempt at sending a transaction, but there should be some way of detecting the problem before then.
I have searched Monks, in CPAN, perldoc, several other perl sites, and whatever books I can get my hands on. All to no avail. It probably is a simple command that I am just overlooking because of my limited perl abilities, so I am hoping that I am not asking to much of the monks.
#!/quovadx/qdx5.1/integrator/bin/perl -w use IO::Socket; use strict; $/ = "\x1c\x0d"; my $sockout; $sockout = new IO::Socket::INET ( PeerAddr => "eng1tst", PeerPort => "9903", Proto => 'tcp', Timeout => 10 ); die "Could not create socket: $!\n" unless $sockout; while (1) { my $msgs = `/hci/qc -IMILTP.CLHADT.RADTG`; my @msgs = split(/\n/,$msgs); my $msg; foreach $msg (@msgs) { print $sockout "$msg"; my $rply = <$sockout>; print STDOUT "$rply\n"; } sleep 10; } close($sockout);
20040903 Janitored by Corion: Replaced TD/TR tags by P tags
20040904 Edit by castaway: Changed title from 'TCP/IP Question'
|
|---|