How to open multiple socket connections and do callbacks in PHP

thotafady

New Member
I'm writing some code which processes a queue of items. The way it works is this:[*]Get the next item flagged as needingto be processed from the mysqldatabase row.[*]Request some info from a google APIusing Curl, wait until the info isreturned.[*]Do the remainder of the processingbased on the info returned.[*]Flag the item as processed in thedb, move onto the next item.The problem is that on step # 2. Google sometimes takes 10-15 seconds to return the requested info, during this time my script has to remain halted and wait. I'm wondering if I could change the code to do the following instead:[*]Get the next 5 items to be processedas usual.[*]Request info for items 1-5 fromgoogle, one after the other.[*]When the info for item 1 isreturned, a 'callback' should bedone which calls up a function orotherwise calls some code which thendoes the remainder of the processingon items 1-5.[*]And then the script starts overuntil all pending items in db aremarked processed.How can something like this be achieved?
 
Back
Top