NYCPHP Meetup

[nycphp-talk] fopen wrappers and timeouts

Hans Zaunere zaunere at yahoo.com
Wed Feb 19 14:27:30 EST 2003


--- 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



More information about the talk mailing list