473,583 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reopening url on failure

Hi,

I was trying to code a script whereby I use fscokopen to load a webpage
into a string, then parse the code.

However, because of occasional timeouts and failures, I was trying to
add a method to attempt to try and reload the URL, say five times,
before it gives up and moves on.

I was playing around with 'do-while' strings, but can't seem to think
my way round this one.

Any ideas ?

Thanks in advance.
SS.

Jul 17 '05 #1
3 1257
Why use a do while when a for loop will work just as well? I really do
not know what your while case is but that works.

This is a way you could do it...

$has_timed_out = true; //expect it to time out
$iterations = 0;
do {
$iterations++;
fsockopen(....) ;
while(!feof(... )) {
$page = fgets(....);
}
fclose(...);
if (!empty($page)) {
$has_timed_out = false;
}
} while ($has_timed_out && ($iterations<5) );

Hope that helps.
Hi,

I was trying to code a script whereby I use fscokopen to load a webpage
into a string, then parse the code.

However, because of occasional timeouts and failures, I was trying to
add a method to attempt to try and reload the URL, say five times,
before it gives up and moves on.

I was playing around with 'do-while' strings, but can't seem to think
my way round this one.

Any ideas ?

Thanks in advance.
SS.

Jul 17 '05 #2
sylvian stone wrote:
Hi,

I was trying to code a script whereby I use fscokopen to load a webpage
into a string, then parse the code.

However, because of occasional timeouts and failures, I was trying to
add a method to attempt to try and reload the URL, say five times,
before it gives up and moves on.


Set timeout parameter to high <http://in2.php.net/fsockopen> . But,
beware the script will hang. If you use session, you should close it;
otherwise, even other scripts will hang.

You seems to be right. AFAIK, the possibility is
<http://in.php.net/ob_start> and <http://in.php.net/preg_replace>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 17 '05 #3
R. Rajesh Jeba Anbiah wrote:
sylvian stone wrote: <snip> You seems to be right. AFAIK, the possibility is
<http://in.php.net/ob_start> and <http://in.php.net/preg_replace>


Oops! Not sure, how it snuck in here.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3138
by: x2164 | last post by:
hi all, Linux 2.4.28 Glibc 2.2.5 gcc 2.95.3 I'm new to Python. I've compiled Python 2.4 from tar file.
3
3745
by: Damaji Jambhale | last post by:
COMException: Catostrphic failure When I added a "dll" reference in the web project. I was able to instantiate the class OK. But when I tried to set the properties, it failed with "COMException: Catostrphic failure". Any idea? Thanks.
2
3081
by: JustaCowboy | last post by:
Greetings, I am seeking information related to this subject. BOL suggests backing up the active transaction log immediately after a failure, so that the backup can be used in a recovery scenario if necessary. This is the relevant text from BOL "Transaction Log Backup": ----// The transaction log backup created at 8:00 P.M. contains...
4
8112
by: J. Marshall Latham | last post by:
I have written an ASP.NET web app in C# that is trying to connect to a database using OleDb. I put code in a dll that uses another dll to create a connection object (and open it if requested) to send back to the web app to connect to the database. I am getting the following error when I change anything in my web app and recompile....
5
5549
by: Ron Louzon | last post by:
I have some C++ code that uses the CSingleLock( CCriticalSection *) constructor. In visual C++ 6.0, this code compiles and runs fine in both Debug and release modes. However, in Visual Studio .Net, when I run this code I get an Assertion failure. The error appears to be exactly the same as that seen with CSingleLock in VC++ version 4.0. I...
8
10155
by: Antony | last post by:
compiler£ºVisual Studio.Net 2003 (VC7.1) compile type£ºDebug problem: wanted more information about the "Run-Time Check Failure #n",thanks! Example1: #include "stdafx.h" void malice() { printf("Hey,you're been attacked.\n");
0
2640
by: Marty Cruise | last post by:
I successfully deploy my application to 20 domain users. Only one new user is giving me a problem, although he can access all domain resources. When he clicks the installation link on the publish page, Framework 2.0 installs successfully, but then the application installation fails during the "Verifying Application Requirements" process. ...
66
3592
by: Johan Tibell | last post by:
I've written a piece of code that uses sockets a lot (I know that sockets aren't portable C, this is not a question about sockets per se). Much of my code ended up looking like this: if (function(socket, args) == -1) { perror("function"); exit(EXIT_FAILURE); } I feel that the ifs destroy the readability of my code. Would it be
1
1861
by: vierling | last post by:
As a digibetic I don't know how to repair Jscript failure (run time failure rule 7 and 5): indicating : object is expected. This is what MS Script Editor tells me, but it doesnot tell me how to repair. It shows a page of Jscript, though, whith a yellow arrow indicating the 'locus delicti' or failure spot: after the Jscript hereunder (unfortunately...
8
3121
by: =?Utf-8?B?TWFyaw==?= | last post by:
We've got a wierd failure happening on just one machine. One part of our product uses a 3rd party search implementation (dtSearch). DtSearch has a native core (dten600.dll), late-bound, and a managed wrapper (dtSearchNetApi2.dll). For reasons unknown our build and msi packaging process includes dtSearchNetApi2.dll but not dten600.dll in...
0
7828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8186
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8329
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8197
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6583
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5704
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3821
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1436
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1160
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.