NYCPHP Meetup

NYPHP.org

[nycphp-talk] fopen wrappers and timeouts

Chris Snyder chris at psydeshow.org
Wed Feb 19 14:45:15 EST 2003


Hans Zaunere wrote:

>--- Chris Snyder <chris at psydeshow.org> wrote:
>  
>
>>Hi folks, does anyone know of a way to cause something like 
>>fopen("http://example.com/") to time out after, say 5 seconds?
>>    
>>
>
>Best use fsockopen():
>
>$fp = fsockopen('example.com',80,$errno,$errstr,5);
>
>Which would try to connect to example.com on port 80 with a timeout of 5
>seconds, writing any error code or string to $errno or $errstr, respectively.
>
>http://us2.php.net/manual/en/function.fsockopen.php
>
>H
>
>  
>
Oh drat, I knew it was something simple. Thanks, Hans.

For any PHP developers lurking on this thread, it would be really great 
to have a settable timeout in the wrappers-- I hate watching my pages 
hang because some other site is down. :-(

Cheers!





More information about the talk mailing list