mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-25 17:32:07 +01:00
171 lines
4.9 KiB
XML
Executable File
171 lines
4.9 KiB
XML
Executable File
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 14dc7c47365f2b71f6c907a5ba5bccf42534d5a9 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry xml:id="function.socket-set-option" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>socket_set_option</refname>
|
|
<refpurpose>Modifie les options de socket</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>socket_set_option</methodname>
|
|
<methodparam><type>Socket</type><parameter>socket</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>level</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>option</parameter></methodparam>
|
|
<methodparam><type class="union"><type>array</type><type>string</type><type>int</type></type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>socket_set_option</function> configure l'option spécifiée par
|
|
<parameter>option</parameter>, au niveau de protocole
|
|
<parameter>level</parameter> à la valeur pointée par
|
|
<parameter>value</parameter> pour le socket spécifié par
|
|
<parameter>socket</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>socket</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Une instance de <classname>Socket</classname> créée par
|
|
<function>socket_create</function> ou <function>socket_accept</function>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>level</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Le paramètre <parameter>level</parameter> spécifie la couche du
|
|
protocole de l'option. Par exemple, pour modifier une option de
|
|
la couche socket, un niveau égal à <constant>SOL_SOCKET</constant>
|
|
va être utilisé. Les autres niveaux, comme TCP, peuvent être
|
|
utilisés en spécifiant un numéro de protocole pour ce niveau.
|
|
Les numéros de protocoles peuvent être utilisés en utilisant la fonction
|
|
<function>getprotobyname</function>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>option</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Les options disponibles sont les mêmes que pour
|
|
la fonction <function>socket_get_option</function>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La valeur de l'option.
|
|
</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>Exemple avec <function>socket_set_option</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
|
|
|
if (!is_resource($socket)) {
|
|
echo 'Impossible de créer le socket : '. socket_strerror(socket_last_error()) . PHP_EOL;
|
|
}
|
|
|
|
if (!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) {
|
|
echo 'Impossible de définir l\'option du socket : '. socket_strerror(socket_last_error()) . PHP_EOL;
|
|
}
|
|
|
|
if (!socket_bind($socket, '127.0.0.1', 1223)) {
|
|
echo 'Impossible de lier le socket : '. socket_strerror(socket_last_error()) . PHP_EOL;
|
|
}
|
|
|
|
$rval = socket_get_option($socket, SOL_SOCKET, SO_REUSEADDR);
|
|
|
|
if ($rval === false) {
|
|
echo 'Impossible de récupérer l\'option du socket : '. socket_strerror(socket_last_error()) . PHP_EOL;
|
|
} else if ($rval !== 0) {
|
|
echo 'SO_REUSEADDR est défini sur le socket !' . PHP_EOL;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>socket_create</function></member>
|
|
<member><function>socket_bind</function></member>
|
|
<member><function>socket_strerror</function></member>
|
|
<member><function>socket_last_error</function></member>
|
|
<member><function>socket_get_option</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
|
|
-->
|