php-doc-en/reference/sockets/functions/socket-set-nonblock.xml
Máté Kocsis 14dc7c4736 Generate sockets methodsynopses based on stubs
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-311.
2021-01-10 19:04:58 +01:00

125 lines
3.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.socket-set-nonblock" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>socket_set_nonblock</refname>
<refpurpose>Sets nonblocking mode for file descriptor fd </refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>socket_set_nonblock</methodname>
<methodparam><type>Socket</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
<para>
The <function>socket_set_nonblock</function> function sets the
<constant>O_NONBLOCK</constant> flag on the socket specified by
the <parameter>socket</parameter> parameter.
</para>
<para>
When an operation (e.g. receive, send, connect, accept, ...) is performed on
a non-blocking socket, the script will not pause its execution until it receives a
signal or it can perform the operation. Rather, if the operation would result
in a block, the called function will fail.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>socket</parameter></term>
<listitem>
<para>
A <classname>Socket</classname> instance created with <function>socket_create</function>
or <function>socket_accept</function>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&sockets.changelog.socket-param;
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>socket_set_nonblock</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$socket = socket_create_listen(1223);
socket_set_nonblock($socket);
socket_accept($socket);
?>
]]>
</programlisting>
<para>
This example creates a listening socket on all interfaces on port 1223 and
sets the socket to <constant>O_NONBLOCK</constant> mode.
<function>socket_accept</function> will immediately fail unless there is a
pending connection exactly at this moment.
</para>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>socket_set_block</function></member>
<member><function>socket_set_option</function></member>
<member><function>stream_set_blocking</function></member>
</simplelist>
</para>
</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
-->