function.socket-get-option.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 367 行 · 第 1/2 页
HTML
367 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Gets socket options for 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-create.html">socket_create</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-getpeername.html">socket_getpeername</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-get-option" class="refentry"> <div class="refnamediv"> <h1 class="refname">socket_get_option</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">socket_get_option</span> — <span class="dc-title">Gets socket options for the socket </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>socket_get_option</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$socket</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$level</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$optname</tt></span> )</div> <p class="para rdfs-comment"> The <b>socket_get_option()</b> function retrieves the value for the option specified by the <i><tt class="parameter">optname</tt></i> parameter for the specified <i><tt class="parameter">socket</tt></i>. </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">level</tt></i></span> <dd> <p class="para"> The <i><tt class="parameter">level</tt></i> parameter specifies the protocol level at which the option resides. For example, to retrieve options at the socket level, a <i><tt class="parameter">level</tt></i> parameter of SOL_SOCKET would be used. Other levels, such as TCP, can be used by specifying the protocol number of that level. Protocol numbers can be found by using the <a href="function.getprotobyname.html" class="function">getprotobyname()</a> function. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">optname</tt></i></span> <dd> <table border="5"> <caption><b>Available Socket Options</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Option</th> <th colspan="1">Description</th> <th colspan="1">Type</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SO_DEBUG</td> <td colspan="1" rowspan="1" align="left"> Reports whether debugging information is being recorded. </td> <td colspan="1" rowspan="1" align="left"> <a href="language.types.integer.html" class="type int">int</a> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SO_BROADCAST</td> <td colspan="1" rowspan="1" align="left"> Reports whether transmission of broadcast messages is supported. </td> <td colspan="1" rowspan="1" align="left"> <a href="language.types.integer.html" class="type int">int</a> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SO_REUSEADDR</td> <td colspan="1" rowspan="1" align="left"> Reports whether local addresses can be reused. </td> <td colspan="1" rowspan="1" align="left"> <a href="language.types.integer.html" class="type int">int</a> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SO_KEEPALIVE</td> <td colspan="1" rowspan="1" align="left"> Reports whether connections are kept active with periodic transmission of messages. If the connected socket fails to respond to these messages, the connection is broken and processes writing to that socket are notified with a SIGPIPE signal. </td> <td colspan="1" rowspan="1" align="left"> <a href="language.types.integer.html" class="type int">int</a> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SO_LINGER</td> <td colspan="1" rowspan="1" align="left"> <p class="para"> Reports whether the <i><tt class="parameter">socket</tt></i> lingers on <a href="function.socket-close.html" class="function">socket_close()</a> if data is present. By default, when the socket is closed, it attempts to send all unsent data. In the case of a connection-oriented socket, <a href="function.socket-close.html" class="function">socket_close()</a> will wait for its peer to acknowledge the data. </p> <p class="para"> If <var class="varname">l_onoff</var> is non-zero and <var class="varname">l_linger</var> is zero, all the unsent data will be discarded and RST (reset) is sent to the peer in the case of a connection-oriented socket. </p> <p class="para"> On the other hand, if <var class="varname">l_onoff</var> is non-zero and <var class="varname">l_linger</var> is non-zero, <a href="function.socket-close.html" class="function">socket_close()</a> will block until all the data is sent or the time specified in <var class="varname">l_linger</var> elapses. If the socket is non-blocking, <a href="function.socket-close.html" class="function">socket_close()</a> will fail and return an error. </p> </td> <td colspan="1" rowspan="1" align="left"> <a href="language.types.array.html" class="type array">array</a>. The array will contain two keys: <var class="varname">l_onoff</var> and <var class="varname">l_linger</var>. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SO_OOBINLINE</td> <td colspan="1" rowspan="1" align="left"> Reports whether the <i><tt class="parameter">socket</tt></i> leaves out-of-band data inline. </td> <td colspan="1" rowspan="1" align="left"> <a href="language.types.integer.html" class="type int">int</a>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?