Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5813

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <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</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.socket-getpeername.html">socket_getpeername</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.socket-import-stream.html">socket_import_stream</a></div>
 <div class="up"><a href="ref.sockets.html">Socket Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><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)</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">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>socket_getsockname</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$socket</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$addr</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$port</code></span>
  ] )</div>

  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
     <span class="function"><strong>socket_getsockname()</strong></span> should not be used with
    <strong><code>AF_UNIX</code></strong> sockets created with  <span class="function"><a href="function.socket-connect.html" class="function">socket_connect()</a></span>.
    Only sockets created with  <span class="function"><a href="function.socket-accept.html" class="function">socket_accept()</a></span> or a primary
    server socket following a call to  <span class="function"><a href="function.socket-bind.html" 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">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">socket</code></em></span>
     <dd>

      <p class="para">
       A valid socket resource created with  <span class="function"><a href="function.socket-create.html" class="function">socket_create()</a></span> 
       or  <span class="function"><a href="function.socket-accept.html" class="function">socket_accept()</a></span>.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">addr</code></em></span>
     <dd>

      <p class="para">
       If the given socket is of type <strong><code>AF_INET</code></strong>
       or <strong><code>AF_INET6</code></strong>,  <span class="function"><strong>socket_getsockname()</strong></span>
       will return the local <em class="emphasis">IP address</em> in appropriate notation (e.g.
       <em>127.0.0.1</em> or <em>fe80::1</em>) in the
       <em><code class="parameter">address</code></em> parameter and, if the optional
       <em><code class="parameter">port</code></em> parameter is present, also the associated port.
      </p>
      <p class="para">
       If the given socket is of type <strong><code>AF_UNIX</code></strong>,
        <span class="function"><strong>socket_getsockname()</strong></span> will return the Unix filesystem
       path (e.g. <em>/var/run/daemon.sock</em>) in the
       <em><code class="parameter">address</code></em> parameter.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">port</code></em></span>
     <dd>

      <p class="para">
       If provided, this will hold the associated port.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.socket-getsockname-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure.  <span class="function"><strong>socket_getsockname()</strong></span> may also return
   <strong><code>FALSE</code></strong> if the socket type is not any of <strong><code>AF_INET</code></strong>,
   <strong><code>AF_INET6</code></strong>, or <strong><code>AF_UNIX</code></strong>, in which
   case the last socket error code is <em class="emphasis">not</em> updated.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.socket-getsockname-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.socket-getpeername.html" class="function" rel="rdfs-seeAlso">socket_getpeername()</a> - Queries the remote side of the given socket which may either result in host/port or in a Unix filesystem path, dependent on its type</span></li>
    <li class="member"> <span class="function"><a href="function.socket-last-error.html" class="function" rel="rdfs-seeAlso">socket_last_error()</a> - Returns the last error on the socket</span></li>
    <li class="member"> <span class="function"><a href="function.socket-strerror.html" class="function" rel="rdfs-seeAlso">socket_strerror()</a> - Return a string describing a socket error</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.socket-getpeername.html">socket_getpeername</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.socket-import-stream.html">socket_import_stream</a></div>
 <div class="up"><a href="ref.sockets.html">Socket Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>