mirror of
https://github.com/php/doc-ja.git
synced 2026-03-26 08:02:15 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@348824 c90b9560-bf6c-de11-be94-00142212c4b1
149 lines
4.0 KiB
XML
149 lines
4.0 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: af6fdf16ab44bcf4d045407963e43c3d9dd2ff29 Maintainer: hirokawa Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
<refentry xml:id="function.stream-set-timeout" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>stream_set_timeout</refname>
|
|
<refpurpose>ストリームにタイムアウトを設定する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>stream_set_timeout</methodname>
|
|
<methodparam><type>resource</type><parameter>stream</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>seconds</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>microseconds</parameter><initializer>0</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<parameter>stream</parameter> にタイムアウトの値を設定します。
|
|
この値は、<parameter>seconds</parameter> と
|
|
<parameter>microseconds</parameter> の和で表されます。
|
|
</para>
|
|
<para>
|
|
ストリームがタイムアウトとなった場合は、
|
|
<function>stream_get_meta_data</function> が返す配列のキー 'timed_out'
|
|
の値が &true; に設定されます。エラーや警告が発生していなくても同様になります。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>stream</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
対象となるストリーム。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>seconds</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
設定したいタイムアウトの秒数部分。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>microseconds</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
設定したいタイムアウトのマイクロ秒数部分。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>stream_set_timeout</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$fp = fsockopen("www.example.com", 80);
|
|
if (!$fp) {
|
|
echo "開けません\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);
|
|
fclose($fp);
|
|
|
|
if ($info['timed_out']) {
|
|
echo 'Connection timed out!';
|
|
} else {
|
|
echo $res;
|
|
}
|
|
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
この関数では、<function>stream_socket_recvfrom</function> のような
|
|
高度な操作はできません。そのかわりに、timeout パラメータを指定して
|
|
<function>stream_select</function> を使用してください。
|
|
</para>
|
|
</note>
|
|
<para>
|
|
この関数は、以前は
|
|
<function>set_socket_timeout</function> 、その後は
|
|
<function>socket_set_timeout</function> と呼ばれたこともありましたが、
|
|
これらの利用は推奨されません。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>fsockopen</function></member>
|
|
<member><function>fopen</function></member>
|
|
</simplelist>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|