Re: Loop while socket connection exists

2007-03-09 Thread Matt
What exactly are you trying to achieve? This is what I'm trying to do - and feel free to tell me I'm wasting my time if there's a better solution. Essentially what I'm trying to do is to create some kind of ftp auto-reconnect feature. I have a few machines that will drop the ftp connectio

Re: Loop while socket connection exists

2007-03-09 Thread Chas Owens
On 3/9/07, Matt <[EMAIL PROTECTED]> wrote: snip You're right, but does it slowdown the script much if if there are two? I only ask because I didn't think about combining them into one line - not questioning your perl know-how. snip It depends on where in the code you do it. In your case you ha

Re: Loop while socket connection exists

2007-03-09 Thread Matt
Jeff Pang wrote: } else { my $whileloop = 99; } Hello, There is a scope mistaken above.You declare $whileloop at the outside of the loop,while here you re-declare another $whileloop with "my".This $whileloop is different from the former one.So "my $whileloop = 99" s

Re: Loop while socket connection exists

2007-03-09 Thread Matt
I don't understand why you are using the $whileloop variable. Perl has perfectly good loop control mechanisms. A quick rewrite would be I think I used it because at first I tried while ($sock) - and that didn't work. So I just used something I 'knew' would always hold true. while (1) {

Re: Loop while socket connection exists

2007-03-09 Thread Steve Bertrand
I don't understand why you are using the $whileloop variable. Perl has perfectly good loop control mechanisms. A quick rewrite would be while (1) { if ($sock) { printf "Socket connected\n"; printf "$counter\n"; $counter++; sleep

Re: Loop while socket connection exists

2007-03-08 Thread Jeff Pang
>} else { >my $whileloop = 99; >} Hello, There is a scope mistaken above.You declare $whileloop at the outside of the loop,while here you re-declare another $whileloop with "my".This $whileloop is different from the former one.So "my $whileloop = 99" shouldn't change th

Re: Loop while socket connection exists

2007-03-08 Thread Chas Owens
On 3/8/07, mlist <[EMAIL PROTECTED]> wrote: I have a script which will create a socket connection to a host. It should loop through while the socket connection is active. The problem is that it still continues to loop even if I take down the interface on the host machine. What am I missing (no

Re: Loop while socket connection exists

2007-03-08 Thread Steve Bertrand
You need to remove the 'my' for $whileloop within the while() statement: while ($whileloop < 1) { if ($sock) { printf "Socket connected\n"; printf "$counter\n"; $counter++; sleep 2; } else { my $whileloop = 99;