Re: [PHP] php conditional loop question

2003-08-14 Thread Randy L Johnson Jr









I am running php as a client and I have the script running 24/7 to download the data from the connection. Is there a function to see if the connection drops. ??


is there a way to keep restart the function in the script. perhaps use a while and exit the function with a number exit(3) and use that value as the condition in the while?




Randy



* Thus wrote Randy L Johnson Jr ([EMAIL PROTECTED]):
 I have done this but it does not seem to ever get to the end of file, I have
 it inserting the values into the database, it goes for awhile around 12 to
 24 hours and then stops inserting the values into the database and I have to
 restart the script...

ah.. so it sound like the connection is dropping at some point thus
your socket becomes not usuable.

From my previous post you can use
 http://php.net/stream_set_timeout



btw, any reason why your using pfsocketopen vs. just fsocketopen?
the pfsocketopen would be only needed if you plan on using that
socket on a different page request.

Come to think of it the pfsocketopen might even give you problems
even if you use the stream_set_timeout function.

HTH,

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

.







 IncrediMail - Email has finally evolved - Click Here

Re: [PHP] php conditional loop question

2003-08-14 Thread Curt Zirzow
* Thus wrote Randy L Johnson Jr ([EMAIL PROTECTED]):
 I have done this but it does not seem to ever get to the end of file, I have
 it inserting the values into the database, it goes for awhile around 12 to
 24 hours and then stops inserting the values into the database and I have to
 restart the script...

ah.. so it sound like the connection is dropping at some point thus
your socket becomes not usuable.

From my previous post you can use
  http://php.net/stream_set_timeout

so if your fread comes back with no data you should exit the
function.

btw, any reason why your using pfsocketopen vs. just fsocketopen?
the pfsocketopen would be only needed if you plan on using that
socket on a different page request.

Come to think of it the pfsocketopen might even give you problems
even if you use the stream_set_timeout function.

HTH,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php conditional loop question

2003-08-14 Thread Curt Zirzow
* Thus wrote Randy L Johnson Jr ([EMAIL PROTECTED]):
 
 I have the program downloading the data and all that so I don't need help
 with that.   I just want to be able to reun the function if the data stops
 or in more general a certain condition is met.

I'm not entirely sure how you are reading the data in from the
socket but your condition is when there is no data that came back
from the socket.

This function might be usefull:
  http://php.net/stream_set_timeout


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php conditional loop question

2003-08-14 Thread Marek Kilimajer
I think you need to set the connection to nonblocking mode. Use
bool stream_set_blocking ( resource stream, int mode)
Then if no data is available for a longer time (it's up to you), you can 
break out of the loop and do something else.

Randy L Johnson Jr wrote:

 

 



I am running php as a client and I have the script running 24/7 to download
the data from the connection.  Is there a function to see if the connection
drops.??


is there a way to keep restart the function in the script.   perhaps use a
while and exit the function with a number exit(3) and use that value as the
condition in the while?








Randy





 

* Thus wrote Randy L Johnson Jr ([EMAIL PROTECTED]):


I have done this but it does not seem to ever get to the end of file, I
have


it inserting the values into the database, it goes for awhile around 12 to


24 hours and then stops inserting the values into the database and I have
to


restart the script...


 

ah.. so it sound like the connection is dropping at some point thus

your socket becomes not usuable.

 

From my previous post you can use
   http://php.net/stream_set_timeout

 



 

btw, any reason why your using pfsocketopen vs. just fsocketopen?

the pfsocketopen would be only needed if you plan on using that

socket on a different page request.

 

Come to think of it the pfsocketopen might even give you problems

even if you use the stream_set_timeout function.

 

HTH,

 

Curt

--

I used to think I was indecisive, but now I'm not so sure.

 

--

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php

 

.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] php conditional loop question

2003-08-14 Thread Analysis Solutions
On Wed, Aug 13, 2003 at 09:51:39PM -0400, Randy L Johnson Jr wrote:
 
 I have a function that makes a connection to a live datafeed website and
 downloads data via a pfsockopen() statement.   After awhile the data stops
 feeding but the connection stays open.   when the data stops I want to exit
 out of the function and have the function run again

Pseudo code...

   while (1) {
   pfsockopen(... blah blah ...);
   while (not end of file) {
   get the line and do what you want with it...
   }
   }

--Dan

-- 
 FREE scripts that make web and database programming easier
   http://www.analysisandsolutions.com/software/
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335   f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php conditional loop question

2003-08-14 Thread Randy L Johnson Jr






I have done this but it does not seem to ever get to the end offile, I have it inserting the values into the database, it goes for awhile around 12 to 24 hours and then stops inserting the values into the database and I have to restart the script...

Randy

---Original Message---


From: Analysis  Solutions
Date: Wednesday, August 13, 2003 10:02:15 PM
To: PHP List
Subject: Re: [PHP] php conditional loop question

On Wed, Aug 13, 2003 at 09:51:39PM -0400, Randy L Johnson Jr wrote:

 I have a function that makes a connection to a live datafeed website and
 downloads data via a pfsockopen() statement. After awhile the data stops
 feeding but the connection stays open. when the data stops I want to exit
 out of the function and have the function run again

Pseudo code...

 while (1) {
 pfsockopen(... blah blah ...);
 while (not end of file) {
 get the line and do what you want with it...
 }
 }

--Dan

--
 FREE scripts that make web and database programming easier
 http://www.analysisandsolutions.com/software/
 T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
 4015 7th Ave #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

.







 IncrediMail - Email has finally evolved - Click Here

[PHP] php conditional loop question

2003-08-14 Thread Randy L Johnson Jr
ok.  This is probably simple but I am not thinking straight.   Here is what
I want to do 


I have a function that makes a connection to a live datafeed website and
downloads data via a pfsockopen() statement.   After awhile the data stops
feeding but the connection stays open.   when the data stops I want to exit
out of the function and have the function run again

basically i don't know how to exit out of the function and have the program
run the function again

I have the program downloading the data and all that so I don't need help
with that.   I just want to be able to reun the function if the data stops
or in more general a certain condition is met.

any ideas and comments would be greatly appreciated.

Randy 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php