View Full Version : Possible to fopen() URLs asynchronously?
06-10-2005, 01:58 PM
I need to fetch and parse 5 to 10 remote files. The parsing is quick and easy, but the fetch is a problem -- 20 to 30 seconds to get each <1K text file. Needless to say, the wait is aggravating.
Is there a way to pipeline fopen() or one its cousins? I'd love to send all the file requests simulataneously, then use callback functions to parse the responses and build my output.
06-14-2005, 06:36 PM
06-14-2005, 06:38 PM
also here, but #1 looks more active:
06-14-2005, 07:21 PM
what is your current code? and what are you doing to the include files. If you are just including them to show there content or use functions you could use include or require. By the sound of it i think you want to do something like search the contents or something?
06-14-2005, 08:09 PM
The files I need to fetch/parse contain a paragraph of text and assorted tab separated values. They're used in a table of a dynamic monitoring page.
Grabbing any one of them, exploding the contents, and splitting the parts ino the HTML of the page-in-progess is simple. The problem comes when the remote server is being slow. By the time the last file trickles in, the first file is outdated. Or the client has push the refreshed button. Or the client browser has timed-out the connection.
The best thing would be to speed up the remote server, but thats out of my control.
Currently, I'm using simple for loop to open/parse the files one at a time. Mostly my script sits idle waiting for the remote server. I'd like to make the requests asynchonously, with callback functions doing the parsing.
Is it possible to do asynchronous requests in php? Any multithreading support at all?
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.