PageRenderTime 58ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/.vim/manual/php/function.socket-get-option.html

https://github.com/urevic/dotfiles
HTML | 531 lines | 463 code | 68 blank | 0 comment | 0 complexity | 3db319c042ffdd338c7991b453627855 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Gets socket options for the socket</title>
  6. </head>
  7. <body><div class="manualnavbar" style="text-align: center;">
  8. <div class="prev" style="text-align: left; float: left;"><a href="function.socket-create.html">socket_create</a></div>
  9. <div class="next" style="text-align: right; float: right;"><a href="function.socket-getpeername.html">socket_getpeername</a></div>
  10. <div class="up"><a href="ref.sockets.html">Socket Functions</a></div>
  11. <div class="home"><a href="index.html">PHP Manual</a></div>
  12. </div><hr /><div id="function.socket-get-option" class="refentry">
  13. <div class="refnamediv">
  14. <h1 class="refname">socket_get_option</h1>
  15. <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">socket_get_option</span> &mdash; <span class="dc-title">Gets socket options for the socket </span></p>
  16. </div>
  17. <div class="refsect1 description" id="refsect1-function.socket-get-option-description">
  18. <h3 class="title">Description</h3>
  19. <div class="methodsynopsis dc-description">
  20. <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b>socket_get_option</b></span>
  21. ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$socket</tt></span>
  22. , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$level</tt></span>
  23. , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$optname</tt></span>
  24. )</div>
  25. <p class="para rdfs-comment">
  26. The <span class="function"><b>socket_get_option()</b></span> function retrieves the value for
  27. the option specified by the <i><tt class="parameter">optname</tt></i> parameter for the
  28. specified <i><tt class="parameter">socket</tt></i>.
  29. </p>
  30. </div>
  31. <div class="refsect1 parameters" id="refsect1-function.socket-get-option-parameters">
  32. <h3 class="title">Parameters</h3>
  33. <p class="para">
  34. <dl>
  35. <dt>
  36. <span class="term"><i><tt class="parameter">socket</tt></i></span>
  37. <dd>
  38. <p class="para">
  39. A valid socket resource created with <span class="function"><a href="function.socket-create.html" class="function">socket_create()</a></span>
  40. or <span class="function"><a href="function.socket-accept.html" class="function">socket_accept()</a></span>.
  41. </p>
  42. </dd>
  43. </dt>
  44. <dt>
  45. <span class="term"><i><tt class="parameter">level</tt></i></span>
  46. <dd>
  47. <p class="para">
  48. The <i><tt class="parameter">level</tt></i> parameter specifies the protocol
  49. level at which the option resides. For example, to retrieve options at
  50. the socket level, a <i><tt class="parameter">level</tt></i> parameter of
  51. <b><tt>SOL_SOCKET</tt></b> would be used. Other levels, such as
  52. <b><tt>TCP</tt></b>, can be used by
  53. specifying the protocol number of that level. Protocol numbers can be
  54. found by using the <span class="function"><a href="function.getprotobyname.html" class="function">getprotobyname()</a></span> function.
  55. </p>
  56. </dd>
  57. </dt>
  58. <dt>
  59. <span class="term"><i><tt class="parameter">optname</tt></i></span>
  60. <dd>
  61. <table class="doctable table">
  62. <caption><b>Available Socket Options</b></caption>
  63. <thead valign="middle">
  64. <tr valign="middle">
  65. <th>Option</th>
  66. <th>Description</th>
  67. <th>Type</th>
  68. </tr>
  69. </thead>
  70. <tbody valign="middle" class="tbody">
  71. <tr valign="middle">
  72. <td align="left"><b><tt>SO_DEBUG</tt></b></td>
  73. <td align="left">
  74. Reports whether debugging information is being recorded.
  75. </td>
  76. <td align="left">
  77. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  78. </td>
  79. </tr>
  80. <tr valign="middle">
  81. <td align="left"><b><tt>SO_BROADCAST</tt></b></td>
  82. <td align="left">
  83. Reports whether transmission of broadcast messages is supported.
  84. </td>
  85. <td align="left">
  86. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  87. </td>
  88. </tr>
  89. <tr valign="middle">
  90. <td align="left"><b><tt>SO_REUSEADDR</tt></b></td>
  91. <td align="left">
  92. Reports whether local addresses can be reused.
  93. </td>
  94. <td align="left">
  95. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  96. </td>
  97. </tr>
  98. <tr valign="middle">
  99. <td align="left"><b><tt>SO_KEEPALIVE</tt></b></td>
  100. <td align="left">
  101. Reports whether connections are kept active with periodic transmission
  102. of messages. If the connected socket fails to respond to these messages,
  103. the connection is broken and processes writing to that socket are notified
  104. with a SIGPIPE signal.
  105. </td>
  106. <td align="left">
  107. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  108. </td>
  109. </tr>
  110. <tr valign="middle">
  111. <td align="left"><b><tt>SO_LINGER</tt></b></td>
  112. <td align="left">
  113. <p class="para">
  114. Reports whether the <i><tt class="parameter">socket</tt></i> lingers on
  115. <span class="function"><a href="function.socket-close.html" class="function">socket_close()</a></span> if data is present. By default,
  116. when the socket is closed, it attempts to send all unsent data.
  117. In the case of a connection-oriented socket,
  118. <span class="function"><a href="function.socket-close.html" class="function">socket_close()</a></span> will wait for its peer to
  119. acknowledge the data.
  120. </p>
  121. <p class="para">
  122. If <var class="varname"><var class="varname">l_onoff</var></var> is non-zero and
  123. <var class="varname"><var class="varname">l_linger</var></var> is zero, all the
  124. unsent data will be discarded and RST (reset) is sent to the
  125. peer in the case of a connection-oriented socket.
  126. </p>
  127. <p class="para">
  128. On the other hand, if <var class="varname"><var class="varname">l_onoff</var></var> is
  129. non-zero and <var class="varname"><var class="varname">l_linger</var></var> is non-zero,
  130. <span class="function"><a href="function.socket-close.html" class="function">socket_close()</a></span> will block until all the data
  131. is sent or the time specified in <var class="varname"><var class="varname">l_linger</var></var>
  132. elapses. If the socket is non-blocking,
  133. <span class="function"><a href="function.socket-close.html" class="function">socket_close()</a></span> will fail and return an error.
  134. </p>
  135. </td>
  136. <td align="left">
  137. <span class="type"><a href="language.types.array.html" class="type array">array</a></span>. The array will contain two keys:
  138. <var class="varname"><var class="varname">l_onoff</var></var> and
  139. <var class="varname"><var class="varname">l_linger</var></var>.
  140. </td>
  141. </tr>
  142. <tr valign="middle">
  143. <td align="left"><b><tt>SO_OOBINLINE</tt></b></td>
  144. <td align="left">
  145. Reports whether the <i><tt class="parameter">socket</tt></i> leaves out-of-band data inline.
  146. </td>
  147. <td align="left">
  148. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  149. </td>
  150. </tr>
  151. <tr valign="middle">
  152. <td align="left"><b><tt>SO_SNDBUF</tt></b></td>
  153. <td align="left">
  154. Reports the size of the send buffer.
  155. </td>
  156. <td align="left">
  157. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  158. </td>
  159. </tr>
  160. <tr valign="middle">
  161. <td align="left"><b><tt>SO_RCVBUF</tt></b></td>
  162. <td align="left">
  163. Reports the size of the receive buffer.
  164. </td>
  165. <td align="left">
  166. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  167. </td>
  168. </tr>
  169. <tr valign="middle">
  170. <td align="left"><b><tt>SO_ERROR</tt></b></td>
  171. <td align="left">
  172. Reports information about error status and clears it.
  173. </td>
  174. <td align="left">
  175. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> (cannot be set by <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  176. </td>
  177. </tr>
  178. <tr valign="middle">
  179. <td align="left"><b><tt>SO_TYPE</tt></b></td>
  180. <td align="left">
  181. Reports the <i><tt class="parameter">socket</tt></i> type (e.g.
  182. <b><tt>SOCK_STREAM</tt></b>).
  183. </td>
  184. <td align="left">
  185. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> (cannot be set by <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  186. </td>
  187. </tr>
  188. <tr valign="middle">
  189. <td align="left"><b><tt>SO_DONTROUTE</tt></b></td>
  190. <td align="left">
  191. Reports whether outgoing messages bypass the standard routing facilities.
  192. </td>
  193. <td align="left">
  194. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  195. </td>
  196. </tr>
  197. <tr valign="middle">
  198. <td align="left"><b><tt>SO_RCVLOWAT</tt></b></td>
  199. <td align="left">
  200. Reports the minimum number of bytes to process for <i><tt class="parameter">socket</tt></i>
  201. input operations.
  202. </td>
  203. <td align="left">
  204. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  205. </td>
  206. </tr>
  207. <tr valign="middle">
  208. <td align="left"><b><tt>SO_RCVTIMEO</tt></b></td>
  209. <td align="left">
  210. Reports the timeout value for input operations.
  211. </td>
  212. <td align="left">
  213. <span class="type"><a href="language.types.array.html" class="type array">array</a></span>. The array will contain two keys:
  214. <var class="varname"><var class="varname">sec</var></var> which is the seconds part on the timeout
  215. value and <var class="varname"><var class="varname">usec</var></var> which is the microsecond part
  216. of the timeout value.
  217. </td>
  218. </tr>
  219. <tr valign="middle">
  220. <td align="left"><b><tt>SO_SNDTIMEO</tt></b></td>
  221. <td align="left">
  222. Reports the timeout value specifying the amount of time that an output
  223. function blocks because flow control prevents data from being sent.
  224. </td>
  225. <td align="left">
  226. <span class="type"><a href="language.types.array.html" class="type array">array</a></span>. The array will contain two keys:
  227. <var class="varname"><var class="varname">sec</var></var> which is the seconds part on the timeout
  228. value and <var class="varname"><var class="varname">usec</var></var> which is the microsecond part
  229. of the timeout value.
  230. </td>
  231. </tr>
  232. <tr valign="middle">
  233. <td align="left"><b><tt>SO_SNDLOWAT</tt></b></td>
  234. <td align="left">
  235. Reports the minimum number of bytes to process for <i><tt class="parameter">socket</tt></i> output operations.
  236. </td>
  237. <td align="left">
  238. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  239. </td>
  240. </tr>
  241. <tr valign="middle">
  242. <td align="left"><b><tt>TCP_NODELAY</tt></b></td>
  243. <td align="left">
  244. Reports whether the Nagle TCP algorithm is disabled.
  245. </td>
  246. <td align="left">
  247. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
  248. </td>
  249. </tr>
  250. <tr valign="middle">
  251. <td align="left"><b><tt>MCAST_JOIN_GROUP</tt></b></td>
  252. <td align="left">
  253. Joins a multicast group. (added in PHP 5.4)
  254. </td>
  255. <td align="left">
  256. <span class="type"><a href="language.types.array.html" class="type array">array</a></span> with keys <i>&quot;group&quot;</i>, specifying
  257. a <span class="type"><a href="language.types.string.html" class="type string">string</a></span> with an IPv4 or IPv6 multicast address and
  258. <i>&quot;interface&quot;</i>, specifying either an interface
  259. number (type <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>) or a <i>string</i> with
  260. the interface name, like <i>&quot;eth0&quot;</i>.
  261. <i>0</i> can be specified to indicate the interface
  262. should be selected using routing rules. (can only be used in
  263. <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  264. </td>
  265. </tr>
  266. <tr valign="middle">
  267. <td align="left"><b><tt>MCAST_LEAVE_GROUP</tt></b></td>
  268. <td align="left">
  269. Leaves a multicast group. (added in PHP 5.4)
  270. </td>
  271. <td align="left">
  272. <span class="type"><a href="language.types.array.html" class="type array">array</a></span>. See <b><tt>MCAST_JOIN_GROUP</tt></b> for
  273. more information. (can only be used in
  274. <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  275. </td>
  276. </tr>
  277. <tr valign="middle">
  278. <td align="left"><b><tt>MCAST_BLOCK_SOURCE</tt></b></td>
  279. <td align="left">
  280. Blocks packets arriving from a specific source to a specific
  281. multicast group, which must have been previously joined.
  282. (added in PHP 5.4)
  283. </td>
  284. <td align="left">
  285. <span class="type"><a href="language.types.array.html" class="type array">array</a></span> with the same keys as
  286. <b><tt>MCAST_JOIN_GROUP</tt></b>, plus one extra key,
  287. <i>source</i>, which maps to a <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
  288. specifying an IPv4 or IPv6 address of the source to be blocked.
  289. (can only be used in <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  290. </td>
  291. </tr>
  292. <tr valign="middle">
  293. <td align="left"><b><tt>MCAST_UNBLOCK_SOURCE</tt></b></td>
  294. <td align="left">
  295. Unblocks (start receiving again) packets arriving from a specific
  296. source address to a specific multicast group, which must have been
  297. previously joined. (added in PHP 5.4)
  298. </td>
  299. <td align="left">
  300. <span class="type"><a href="language.types.array.html" class="type array">array</a></span> with the same format as
  301. <b><tt>MCAST_BLOCK_SOURCE</tt></b>.
  302. (can only be used in <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  303. </td>
  304. </tr>
  305. <tr valign="middle">
  306. <td align="left"><b><tt>MCAST_JOIN_SOURCE_GROUP</tt></b></td>
  307. <td align="left">
  308. Receive packets destined to a specific multicast group whose source
  309. address matches a specific value. (added in PHP 5.4)
  310. </td>
  311. <td align="left">
  312. <span class="type"><a href="language.types.array.html" class="type array">array</a></span> with the same format as
  313. <b><tt>MCAST_BLOCK_SOURCE</tt></b>.
  314. (can only be used in <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  315. </td>
  316. </tr>
  317. <tr valign="middle">
  318. <td align="left"><b><tt>MCAST_LEAVE_SOURCE_GROUP</tt></b></td>
  319. <td align="left">
  320. Stop receiving packets destined to a specific multicast group whose
  321. soure address matches a specific value. (added in PHP 5.4)
  322. </td>
  323. <td align="left">
  324. <span class="type"><a href="language.types.array.html" class="type array">array</a></span> with the same format as
  325. <b><tt>MCAST_BLOCK_SOURCE</tt></b>.
  326. (can only be used in <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>)
  327. </td>
  328. </tr>
  329. <tr valign="middle">
  330. <td align="left"><b><tt>IP_MULTICAST_IF</tt></b></td>
  331. <td align="left">
  332. The outgoing interface for IPv4 multicast packets.
  333. (added in PHP 5.4)
  334. </td>
  335. <td align="left">
  336. Either <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> specifying the interface number or a
  337. <span class="type"><a href="language.types.string.html" class="type string">string</a></span> with an interface name, like
  338. <i>eth0</i>. The value <span class="type"><span class="type 0">0</span></span> can be used to
  339. indicate the routing table is to used in the interface selection.
  340. The function <span class="function"><b>socket_get_option()</b></span> returns an
  341. interface index.
  342. Note that, unlike the C API, this option does NOT take an IP
  343. address. This eliminates the interface difference between
  344. <b><tt>IP_MULTICAST_IF</tt></b> and
  345. <b><tt>IPV6_MULTICAST_IF</tt></b>.
  346. </td>
  347. </tr>
  348. <tr valign="middle">
  349. <td align="left"><b><tt>IPV6_MULTICAST_IF</tt></b></td>
  350. <td align="left">
  351. The outgoing interface for IPv6 multicast packets.
  352. (added in PHP 5.4)
  353. </td>
  354. <td align="left">
  355. The same as <b><tt>IP_MULTICAST_IF</tt></b>.
  356. </td>
  357. </tr>
  358. <tr valign="middle">
  359. <td align="left"><b><tt>IP_MULTICAST_LOOP</tt></b></td>
  360. <td align="left">
  361. The multicast loopback policy for IPv4 packets, which
  362. determines whether multicast packets sent by this socket also reach
  363. receivers in the same host that have joined the same multicast group
  364. on the outgoing interface used by this socket. This is the case by
  365. default.
  366. (added in PHP 5.4)
  367. </td>
  368. <td align="left">
  369. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> (either <i>0</i> or
  370. <i>1</i>). For <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span>
  371. any value will be accepted and will be converted to a boolean
  372. following the usual PHP rules.
  373. </td>
  374. </tr>
  375. <tr valign="middle">
  376. <td align="left"><b><tt>IPV6_MULTICAST_LOOP</tt></b></td>
  377. <td align="left">
  378. Analogous to <b><tt>IP_MULTICAST_LOOP</tt></b>, but for IPv6.
  379. (added in PHP 5.4)
  380. </td>
  381. <td align="left">
  382. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>. See <b><tt>IP_MULTICAST_LOOP</tt></b>.
  383. </td>
  384. </tr>
  385. <tr valign="middle">
  386. <td align="left"><b><tt>IP_MULTICAST_TTL</tt></b></td>
  387. <td align="left">
  388. The time-to-live of outgoing IPv4 multicast packets. This should be
  389. a value between 0 (don&#039;t leave the interface) and 255. The default
  390. value is 1 (only the local network is reached).
  391. (added in PHP 5.4)
  392. </td>
  393. <td align="left">
  394. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> between 0 and 255.
  395. </td>
  396. </tr>
  397. <tr valign="middle">
  398. <td align="left"><b><tt>IPV6_MULTICAST_HOPS</tt></b></td>
  399. <td align="left">
  400. Analogous to <b><tt>IP_MULTICAST_TTL</tt></b>, but for IPv6
  401. packets. The value -1 is also accepted, meaning the route default
  402. should be used.
  403. (added in PHP 5.4)
  404. </td>
  405. <td align="left">
  406. <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> between -1 and 255.
  407. </td>
  408. </tr>
  409. </tbody>
  410. </table>
  411. </dd>
  412. </dt>
  413. </dl>
  414. </p>
  415. </div>
  416. <div class="refsect1 returnvalues" id="refsect1-function.socket-get-option-returnvalues">
  417. <h3 class="title">Return Values</h3>
  418. <p class="para">
  419. Returns the value of the given option, or <b><tt>FALSE</tt></b> on errors.
  420. </p>
  421. </div>
  422. <div class="refsect1 examples" id="refsect1-function.socket-get-option-examples">
  423. <h3 class="title">Examples</h3>
  424. <p class="para">
  425. <div class="example" id="example-4081">
  426. <p><b>Example #1 <span class="function"><a href="function.socket-set-option.html" class="function">socket_set_option()</a></span> example</b></p>
  427. <div class="example-contents">
  428. <div class="phpcode"><code><span style="color: #000000">
  429. <span style="color: #0000BB">&lt;?php<br />$socket&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">socket_create_listen</span><span style="color: #007700">(</span><span style="color: #0000BB">1223</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$linger&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'l_linger'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'l_onoff'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">socket_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$socket</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SOL_SOCKET</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SO_LINGER</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$linger</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">socket_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$socket</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SOL_SOCKET</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SO_REUSEADDR</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
  430. </span>
  431. </code></div>
  432. </div>
  433. </div>
  434. </p>
  435. </div>
  436. <div class="refsect1 changelog" id="refsect1-function.socket-get-option-changelog">
  437. <h3 class="title">Changelog</h3>
  438. <p class="para">
  439. <table class="doctable informaltable">
  440. <thead valign="middle">
  441. <tr valign="middle">
  442. <th>Version</th>
  443. <th>Description</th>
  444. </tr>
  445. </thead>
  446. <tbody valign="middle" class="tbody">
  447. <tr valign="middle">
  448. <td align="left">4.3.0</td>
  449. <td align="left">
  450. The name of this function was changed. It used to be called
  451. <i>socket_getopt()</i>.
  452. </td>
  453. </tr>
  454. </tbody>
  455. </table>
  456. </p>
  457. </div>
  458. </div><hr /><div class="manualnavbar" style="text-align: center;">
  459. <div class="prev" style="text-align: left; float: left;"><a href="function.socket-create.html">socket_create</a></div>
  460. <div class="next" style="text-align: right; float: right;"><a href="function.socket-getpeername.html">socket_getpeername</a></div>
  461. <div class="up"><a href="ref.sockets.html">Socket Functions</a></div>
  462. <div class="home"><a href="index.html">PHP Manual</a></div>
  463. </div></body></html>