Sep
17
2010
stream_set_timeout()

stream_set_timeout

(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. Возвращает TRUE в случае успешного завершения или 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.


<?php
$fp 
fsockopen("www..com"80);
if (!
$fp) {
    echo 
"Unable to open\n";
} else {

    
fwrite($fp"GET / HTTP/1.0\r\n\r\n");
    
stream_set_timeout($fp2);
    
$res fread($fp2000);

    
$info stream_get_meta_data($fp);
    
fclose($fp);

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

}
?>

Замечание: 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 /component/search/f=

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

See also fsockopen() and fopen().

 
 
 
Комментарии
Добавить новый Поиск
Оставить комментарий
Имя:
Email:
 
Веб-сайт:
Тема:
UBB-Код:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Пожалуйста, введите проверочный код, который Вы видите на картинке.
Powered by !JoomlaComment 3.26

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Кто онлайн

Сейчас 23 гостей онлайн