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

📄 function.socket-last-error.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>Returns the last error on the socket</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-getsockname.html">socket_getsockname</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-listen.html">socket_listen</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-last-error" class="refentry"> <div class="refnamediv">  <h1 class="refname">socket_last_error</h1>  <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5)</p><p class="refpurpose"><span class="refname">socket_last_error</span> &mdash; <span class="dc-title">Returns the last error on the socket </span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">int</span> <span class="methodname"><b><b>socket_last_error</b></b></span>    ([ <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$socket</tt></span>  ] )</div>  <p class="para rdfs-comment">   If a socket resource is passed to this function, the last error which   occurred on this particular socket is returned. If the socket resource is   omitted, the error code of the last failed socket function is returned.   The latter is particularly helpful for functions like   <a href="function.socket-create.html" class="function">socket_create()</a> which don&#039;t return a socket on   failure and <a href="function.socket-select.html" class="function">socket_select()</a> which can fail for reasons   not directly tied to a particular socket.  The error code is suitable to   be fed to <a href="function.socket-strerror.html" class="function">socket_strerror()</a> which returns a string   describing the given error code.  </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>.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   This function returns a socket error code.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 <b>socket_last_error()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$socket&nbsp;</span><span style="color: #007700">=&nbsp;@</span><span style="color: #0000BB">socket_create</span><span style="color: #007700">(</span><span style="color: #0000BB">AF_INET</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SOCK_STREAM</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SOL_TCP</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$socket&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$errorcode&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">socket_last_error</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$errormsg&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">socket_strerror</span><span style="color: #007700">(</span><span style="color: #0000BB">$errorcode</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Couldn't&nbsp;create&nbsp;socket:&nbsp;[$errorcode]&nbsp;$errormsg"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div> <div class="refsect1 notes">  <h3 class="title">Notes</h3>  <blockquote><p><b class="note">Note</b>:        <b>socket_last_error()</b> does not clear the error code, use    <a href="function.socket-clear-error.html" class="function">socket_clear_error()</a> for this purpose.   <br />  </p></blockquote> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.socket-getsockname.html">socket_getsockname</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-listen.html">socket_listen</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 + -