Dynamic Web Pages: deutschsprachiger PHP Knotenpunkt seit 1999

Dynamic Web Pages : deutschsprachiges PHP-Handbuch : stream-set-timeout _

  PHP Architect  
<stream_set_blocking stream_set_write_buffer>
Letzte Aktualisierung: Mon, 20 Oct 2014


(PHP 4 >= 4.3.0, PHP 5)

stream_set_timeout -- Set timeout period on a stream


bool stream_set_timeout ( resource stream, int seconds [, int microseconds] )

Sets the timeout value on stream, expressed in the sum of seconds and microseconds. Gibt bei Erfolg TRUE zurück, im Fehlerfall FALSE.

When the stream times out, the 'timed_out' key of the array returned by stream_get_meta_data() is set to TRUE, although no error/warning is generated.

Beispiel 1. stream_set_timeout() example

= fsockopen("www.example.com", 80);
if (!
$fp) {
"Unable to open\n";
} else {

fwrite($fp, "GET / HTTP/1.0\r\n\r\n");
stream_set_timeout($fp, 2);
$res = fread($fp, 2000);

$info = stream_get_meta_data($fp);

   if (
$info['timed_out']) {
'Connection timed out!';
   } else {


Anmerkung: As of PHP 4.3, this function can (potentially) work on any kind of stream. In PHP 4.3, socket based streams are still the only kind supported in the PHP core, although streams from other extensions may support this function.

Anmerkung: This function doesn't work with advanced operations like stream_socket_recvfrom(), use stream_select() with timeout parameter instead.

This function was previously called as set_socket_timeout() and later socket_set_timeout() but this usage is deprecated.

See also fsockopen() and fopen().

<stream_set_blocking stream_set_write_buffer>
Letzte Aktualisierung: Mon, 20 Oct 2014

powered by Hetzner
top Alle Rechte vorbehalten. © Dynamic Web Pages 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 top

Werbung an/aus Werbung aus Werbung an