<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.socket-getsockname.php',
    1 => 'socket_getsockname',
    2 => 'Queries the local side of the given socket which may either result in host/port or in a Unix filesystem path, dependent on its type',
  ),
  'up' => 
  array (
    0 => 'ref.sockets.php',
    1 => 'Socket Функції',
  ),
  'prev' => 
  array (
    0 => 'function.socket-getpeername.php',
    1 => 'socket_getpeername',
  ),
  'next' => 
  array (
    0 => 'function.socket-import-stream.php',
    1 => 'socket_import_stream',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sockets/functions/socket-getsockname.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.socket-getsockname" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">socket_getsockname</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">socket_getsockname</span> &mdash; <span class="dc-title">Queries the local side of the given socket which may either result in host/port or in a Unix filesystem path, dependent on its type</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.socket-getsockname-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>socket_getsockname</strong></span>(<span class="methodparam"><span class="type"><a href="class.socket.php" class="type Socket">Socket</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 reference">&$address</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter reference">&$port</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <span class="simpara">
    <span class="function"><strong>socket_getsockname()</strong></span> should not be used with
    <strong><code><a href="sockets.constants.php#constant.af-unix">AF_UNIX</a></code></strong> sockets created with <span class="function"><a href="function.socket-connect.php" class="function">socket_connect()</a></span>.
    Only sockets created with <span class="function"><a href="function.socket-accept.php" class="function">socket_accept()</a></span> or a primary
    server socket following a call to <span class="function"><a href="function.socket-bind.php" class="function">socket_bind()</a></span> will return
    meaningful values.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.socket-getsockname-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">socket</code></dt>
     <dd>
      <p class="para">
       A <span class="classname"><a href="class.socket.php" class="classname">Socket</a></span> instance created with <span class="function"><a href="function.socket-create.php" class="function">socket_create()</a></span>
       or <span class="function"><a href="function.socket-accept.php" class="function">socket_accept()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">address</code></dt>
     <dd>
      <p class="para">
       If the given socket is of type <strong><code><a href="sockets.constants.php#constant.af-inet">AF_INET</a></code></strong>
       or <strong><code><a href="sockets.constants.php#constant.af-inet6">AF_INET6</a></code></strong>, <span class="function"><strong>socket_getsockname()</strong></span>
       will return the local <em>IP address</em> in appropriate notation (e.g.
       <code class="literal">127.0.0.1</code> or <code class="literal">fe80::1</code>) in the
       <code class="parameter">address</code> parameter and, if the optional
       <code class="parameter">port</code> parameter is present, also the associated port.
      </p>
      <p class="para">
       If the given socket is of type <strong><code><a href="sockets.constants.php#constant.af-unix">AF_UNIX</a></code></strong>,
       <span class="function"><strong>socket_getsockname()</strong></span> will return the Unix filesystem
       path (e.g. <code class="literal">/var/run/daemon.sock</code>) in the
       <code class="parameter">address</code> parameter.
      </p>
     </dd>
    
    
     <dt><code class="parameter">port</code></dt>
     <dd>
      <p class="para">
       If provided, this will hold the associated port.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.socket-getsockname-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Повертає <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> у разі успіху або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки. <span class="function"><strong>socket_getsockname()</strong></span> may also return
   <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the socket type is not any of <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>, or <strong><code><a href="sockets.constants.php#constant.af-unix">AF_UNIX</a></code></strong>, in which
   case the last socket error code is <em>not</em> updated.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.socket-getsockname-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
  <td>8.0.0</td>
  <td>
   Тепер <code class="parameter">socket</code> є примірником
   <span class="classname"><a href="class.socket.php" class="classname">Socket</a></span>; раніше це був <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
  </td>
 </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.socket-getsockname-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.socket-getpeername.php" class="function" rel="rdfs-seeAlso">socket_getpeername()</a> - Queries the remote side of the given socket</span></li>
    <li><span class="function"><a href="function.socket-last-error.php" class="function" rel="rdfs-seeAlso">socket_last_error()</a> - Returns the last error on the socket</span></li>
    <li><span class="function"><a href="function.socket-strerror.php" class="function" rel="rdfs-seeAlso">socket_strerror()</a> - Return a string describing a socket error</span></li>
   </ul>
  </p>
 </div>


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