Gorby has asked for the wisdom of the Perl Monks concerning the following question:
Hello wise monks. I need to write code that will stay connected to another server continuously 24x7. Will the following code do the job? Or should I use infinite loops? If so, how?
Thanksuse IO::Socket; use strict; my $socket; my $line; my $child_pid; $socket = IO::Socket::INET->new ( PeerAddr => 'server.com', PeerPort => 1247, Proto => "tcp", Type => SOCK_STREAM ) or die "Could not create client.\n"; unless (defined($child_pid = fork())) {die "Cannot fork.\n"}; if ($child_pid) { while($line = <>) { #here I'm gonna make the server read some files and #throw stuff to the other socket } } else { while ($line = <$socket>) { #here I'm gonna make the server listen for stuff from #the other socket. The information that comes from this #connection will be store in files that will be accessed #by the parent process. Is this gonna work? 24x7? #Non-stop? } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Need Help with Sockets, Please
by broquaint (Abbot) on May 09, 2002 at 14:19 UTC | |
Re: Need Help with Sockets, Please
by ferrency (Deacon) on May 09, 2002 at 14:19 UTC | |
Re: Need Help with Sockets, Please
by ozone (Friar) on May 09, 2002 at 14:24 UTC | |
If you have some $$$
by Rex(Wrecks) (Curate) on May 09, 2002 at 17:14 UTC |
Back to
Seekers of Perl Wisdom