Timing out a remote call

From: Date: Thu, 04 Aug 2005 22:01:22 +0000
Subject: Timing out a remote call
Groups: php.general 
Request: Send a blank email to php-general+get-220036@lists.php.net to get a copy of this message
For one project, I'm required to access a web service for every page. Basically it returns a little bit of random text. I have no control over the web service, and there is no possibility of cacheing or bringing it locally: the requirements are that it be accessed live across the Internet every time. Most times it's instantaneous, but sometimes it can hang. I want to give it a half-second timeout, which we're allowed to do, but there's no documentation provided. Here is how we call it now (really simple): include('http://04planet.info/kfc/grab_one.php'); I have STFW and RTFM and could only find vague references like "use fsockopen instead" or "stream_set_timeout()" but I can't find an actual complete working example anywhere. Any pointers?

« previous php.general (#220036) next »