⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.socket-getpeername.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>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</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.socket-get-option.html">socket_get_option</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-getsockname.html">socket_getsockname</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-getpeername" class="refentry"> <div class="refnamediv">  <h1 class="refname">socket_getpeername</h1>  <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5)</p><p class="refpurpose"><span class="refname">socket_getpeername</span> &mdash; <span class="dc-title">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></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">bool</span> <span class="methodname"><b><b>socket_getpeername</b></b></span>    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$socket</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter reference">&$address</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&$port</tt></span>  ] )</div>  <p class="para rdfs-comment">   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.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">socket</tt></i></span>     <dd>      <p class="para">       A valid socket resource created with <a href="function.socket-create.html" class="function">socket_create()</a>       or <a href="function.socket-accept.html" class="function">socket_accept()</a>.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">address</tt></i></span>     <dd>      <p class="para">       If the given socket is of type <b><tt>AF_INET</tt></b> or       <b><tt>AF_INET6</tt></b>, <b>socket_getpeername()</b>       will return the peers (remote) <em class="emphasis">IP address</em> in       appropriate notation (e.g. <i>127.0.0.1</i> or       <i>fe80::1</i>) in the <i><tt class="parameter">address</tt></i>       parameter and, if the optional <i><tt class="parameter">port</tt></i> parameter is       present, also the associated port.      </p>      <p class="para">       If the given socket is of type <b><tt>AF_UNIX</tt></b>,       <b>socket_getpeername()</b> will return the Unix filesystem       path (e.g. <i>/var/run/daemon.sock</i>) in the       <i><tt class="parameter">address</tt></i> parameter.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">port</tt></i></span>     <dd>      <p class="para">       If given, this will hold the port associated to       <i><tt class="parameter">address</tt></i>.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. <b>socket_getpeername()</b> may also return   <b><tt>FALSE</tt></b> if the socket type is not any of <b><tt>AF_INET</tt></b>,   <b><tt>AF_INET6</tt></b>, or <b><tt>AF_UNIX</tt></b>, in which   case the last socket error code is <em class="emphasis">not</em> updated.  </p> </div> <div class="refsect1 notes">  <h3 class="title">Notes</h3>  <blockquote><p><b class="note">Note</b>:        <b>socket_getpeername()</b> should not be used with    <b><tt>AF_UNIX</tt></b> sockets created with <a href="function.socket-accept.html" class="function">socket_accept()</a>.    Only sockets created with <a href="function.socket-connect.html" class="function">socket_connect()</a> or a primary    server socket following a call to <a href="function.socket-bind.html" class="function">socket_bind()</a> will return    meaningful values.   <br />  </p></blockquote> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.socket-getsockname.html" class="function" rel="rdfs-seeAlso">socket_getsockname()</a></li>    <li class="member"><a href="function.socket-last-error.html" class="function" rel="rdfs-seeAlso">socket_last_error()</a></li>    <li class="member"><a href="function.socket-strerror.html" class="function" rel="rdfs-seeAlso">socket_strerror()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.socket-get-option.html">socket_get_option</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-getsockname.html">socket_getsockname</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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -