<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.sockets.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.socket-getpeername.php',
    1 => 'socket_getpeername',
    2 => 'Interroga il lato remoto di un dato socket per ottenere o la combinazione host/porta
     od un percorso Unix, in base al tipo di socket',
  ),
  'up' => 
  array (
    0 => 'ref.sockets.php',
    1 => 'Socket Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.socket-getopt.php',
    1 => 'socket_getopt',
  ),
  'next' => 
  array (
    0 => 'function.socket-getsockname.php',
    1 => 'socket_getsockname',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/sockets/functions/socket-getpeername.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.socket-getpeername" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">socket_getpeername</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">socket_getpeername</span> &mdash; <span class="dc-title">
     Interroga il lato remoto di un dato socket per ottenere o la combinazione host/porta
     od un percorso Unix, in base al tipo di socket
    </span></p>

   </div>
   <div class="refsect1 unknown-1141" id="refsect1-function.socket-getpeername-unknown-1141">
    <h3 class="title">Descrizione</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>socket_getpeername</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$socket</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$&amp;indirizzo</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$&amp;porta</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

     <div class="warning"><strong class="warning">Avviso</strong><p class="simpara">Questa funzione è
<em>SPERIMENTALE</em>. Ovvero, il comportamento di questa funzione,
il nome di questa funzione, in definitiva tutto ciò che è documentato qui 
può cambiare nei futuri rilasci del PHP senza preavviso. Siete avvisati, l&#039;uso di questa
funzione è a vostro rischio.</p></div>
    <p class="para">
     Se il socket dato è di tipo <strong><code><a href="sockets.constants.php#constant.af-inet">AF_INET</a></code></strong> oppure <strong><code><a href="sockets.constants.php#constant.af-inet6">AF_INET6</a></code></strong>,
     <span class="function"><strong>socket_getpeername()</strong></span> restituisce l&#039;<em>indirizzo IP</em>
     remoto nella notazione appropriata (ad esempio
     <code class="literal">127.0.0.1</code> oppure <code class="literal">fe80::1</code>) nel parametro <code class="parameter">indirizzo</code>
     e, se presente il parametro opzionale <code class="parameter">porta</code>,
     anche la porta associata.
    </p>
    <p class="para">
     Se il socket dato è di tipo <strong><code><a href="sockets.constants.php#constant.af-unix">AF_UNIX</a></code></strong>,
     <span class="function"><strong>socket_getpeername()</strong></span> restituirà un percorso Unix
     (ad esempio <code class="literal">/var/run/daemon.sock</code>) nel
     parametro <code class="parameter">indirizzo</code>.
    </p>
    <blockquote class="note"><p><strong class="note">Nota</strong>: 
     <span class="simpara">
      La funzione <span class="function"><strong>socket_getpeername()</strong></span> non dovrebbe essere usata con socket
      <strong><code><a href="sockets.constants.php#constant.af-unix">AF_UNIX</a></code></strong> creati da <span class="function"><a href="function.socket-accept.php" class="function">socket_accept()</a></span>.
      Soltanto i socket creati con <span class="function"><a href="function.socket-connect.php" class="function">socket_connect()</a></span> o un socket
      server primario conseguente alla chiamata di <span class="function"><a href="function.socket-bind.php" class="function">socket_bind()</a></span> restituirà
      dei valori significativi.
     </span>
    </p></blockquote>
    <p class="para">
     Restituisce <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> in caso di successo, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento. <span class="function"><strong>socket_getpeername()</strong></span> può anche restituire
     <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> se il tipo di socket non è <strong><code><a href="sockets.constants.php#constant.af-inet">AF_INET</a></code></strong>, <strong><code><a href="sockets.constants.php#constant.af-inet6">AF_INET6</a></code></strong> o
     <strong><code><a href="sockets.constants.php#constant.af-unix">AF_UNIX</a></code></strong>, in questo caso l&#039;ultimo codice di errore del socket
     <em>non</em> viene aggiornato.
    </p>
    <p class="para">
     Vedere anche
     <span class="function"><a href="function.socket-getsockname.php" class="function">socket_getsockname()</a></span>,
     <span class="function"><a href="function.socket-last-error.php" class="function">socket_last_error()</a></span> e
     <span class="function"><a href="function.socket-strerror.php" class="function">socket_strerror()</a></span>.
    </p>
   </div>

  </div><?php manual_footer($setup); ?>