1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-27 09:12:07 +01:00
Files
archived-doc-ru/reference/sockets/functions/socket-getpeername.xml
2024-07-08 17:02:17 +03:00

146 lines
5.9 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 5eaa3458d57434d0ce08207726a7d25df2994c6d Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.socket-getpeername" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>socket_getpeername</refname>
<refpurpose>Опрашивает удалённую сторону сокета</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>socket_getpeername</methodname>
<methodparam><type>Socket</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter role="reference">address</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter role="reference">port</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Функция отправляет запрос удалённой стороне заданного сокета, которая возвращает
либо хост и порт, либо путь в файловой системе Unix, в зависимости от типа сокета.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>socket</parameter></term>
<listitem>
<para>
Экземпляр <classname>Socket</classname>, который создали функциями
<function>socket_create</function> или <function>socket_accept</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>address</parameter></term>
<listitem>
<para>
Если тип сокета относится к семейству IPv4-адресов <constant>AF_INET</constant> или IPv6-адресов <constant>AF_INET6</constant>:
функция <function>socket_getpeername</function>
заполнит параметр <parameter>address</parameter>
значением <emphasis>IP-адреса</emphasis> однорангового (удалённого) узла в нотации, которая
соответствует версии протокола — <literal>127.0.0.1</literal> или <literal>fe80::1</literal>.
Функция также вернёт связанный с адресом порт, если указали необязательный параметр <parameter>port</parameter>.
</para>
<para>
Если тип сокета относится к семейству адресов файловой системы Unix <constant>AF_UNIX</constant>:
функция <function>socket_getpeername</function> заполнит параметр
<parameter>address</parameter> значением пути в файловой системе Unix.
Например: <literal>/var/run/daemon.sock</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>port</parameter></term>
<listitem>
<para>
Функция заполнит параметр номером порта, который связан параметром <parameter>address</parameter>,
если порт указали.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success; Функция <function>socket_getpeername</function> также может вернуть
&false;, если тип сокета не совпадает со значениями констант <constant>AF_INET</constant>,
<constant>AF_INET6</constant> или <constant>AF_UNIX</constant>;
код последней ошибки сокета <emphasis>не</emphasis> обновляется, если возник такой случай.
</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="notes">
&reftitle.notes;
<note>
<para>
Функцию <function>socket_getpeername</function> не следует вызывать
с <constant>AF_UNIX</constant>-сокетами, которые создали функцией <function>socket_accept</function>.
Возвращать осмысленные значения будут только сокеты, которые создали функцией <function>socket_connect</function>,
или сокет основного сервера после вызова функции <function>socket_bind</function>.
</para>
</note>
<note>
<para>
Функция <function>socket_getpeername</function> возвращает осмысленное значение
только для тех сокетов, для которых концепция «одноранговых отношений» имеет смысл.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>socket_getsockname</function></member>
<member><function>socket_last_error</function></member>
<member><function>socket_strerror</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
-->