diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2026-09-01 10:00:21 +0200 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2026-09-01 10:48:40 +0200 |
| commit | 70f7800986812ad0d1a5dd6f280f66fd2bf1dd12 (patch) | |
| tree | 36051874b3ce036307d4bb69b3c4058458b6255d /docs | |
| parent | fa9b35a0cf11bc856cbd8bffbef5ad6fb3e62a93 (diff) | |
| download | luasocket-docs/pre-release-audit.tar.gz luasocket-docs/pre-release-audit.tar.bz2 luasocket-docs/pre-release-audit.zip | |
docs: document socket.unix and socket.serial, fix stale/missing API referencesdocs/pre-release-audit
Pre-release documentation audit against master. Adds the two fully
undocumented modules and closes gaps found by diffing every docs/*.html
page against its corresponding source:
- New docs/unix.html and docs/serial.html (socket.unix stream/dgram and
socket.serial were never documented), linked from index.html,
introduction.html, socket.html and reference.html. serial.html notes
the current lack of a baud/parity/flow-control API and includes an
os.execute+stty workaround example. Both note Windows is unsupported.
- socket.html: document headers.setcanonic, point to unix/serial modules.
- tcp.html: document getfamily, setpeername/setsockname aliases.
- udp.html: document getfamily, getfd/setfd, dirty; document the
ipv6-multicast-hops/ipv6-unicast-hops aliasing as current (known-buggy)
behavior rather than the originally intended semantics.
- http.html: correct redirect text (301/302/303/307/308, was 301/302
only); document MAXHEADERLINE/MAXHEADERSIZE.
- dns.html: document getnameinfo.
- ltn12.html: document source.rewind and BLOCKSIZE.
- installation.html: fix stale "LuaSocket 3.0" sample output to 3.1.0.
- reference.html: index every anchor added above plus new Unix/Serial
blocks.
Diffstat (limited to '')
| -rw-r--r-- | docs/dns.html | 26 | ||||
| -rw-r--r-- | docs/http.html | 9 | ||||
| -rw-r--r-- | docs/index.html | 2 | ||||
| -rw-r--r-- | docs/installation.html | 2 | ||||
| -rw-r--r-- | docs/introduction.html | 5 | ||||
| -rw-r--r-- | docs/ltn12.html | 38 | ||||
| -rw-r--r-- | docs/reference.html | 72 | ||||
| -rw-r--r-- | docs/serial.html | 308 | ||||
| -rw-r--r-- | docs/socket.html | 29 | ||||
| -rw-r--r-- | docs/tcp.html | 43 | ||||
| -rw-r--r-- | docs/udp.html | 88 | ||||
| -rw-r--r-- | docs/unix.html | 795 |
12 files changed, 1411 insertions, 6 deletions
diff --git a/docs/dns.html b/docs/dns.html index 56ce3ba..e8320e8 100644 --- a/docs/dns.html +++ b/docs/dns.html | |||
| @@ -106,6 +106,32 @@ the resolver. In case of error, the function returns <b><tt>nil</tt></b> | |||
| 106 | followed by an error message. | 106 | followed by an error message. |
| 107 | </p> | 107 | </p> |
| 108 | 108 | ||
| 109 | <!-- getnameinfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 110 | |||
| 111 | <p class="name" id="getnameinfo"> | ||
| 112 | socket.dns.<b>getnameinfo(</b>[host] [, service]<b>)</b> | ||
| 113 | </p> | ||
| 114 | |||
| 115 | <p class="description"> | ||
| 116 | Resolves a host and/or a service name through the system resolver and | ||
| 117 | returns their canonical name form. At least one of <tt>host</tt> or | ||
| 118 | <tt>service</tt> must be given. | ||
| 119 | </p> | ||
| 120 | |||
| 121 | <p class="parameters"> | ||
| 122 | <tt>Host</tt> is an optional string with a host name or IP address. | ||
| 123 | <tt>Service</tt> is an optional string with a service name or port number. | ||
| 124 | </p> | ||
| 125 | |||
| 126 | <p class="return"> | ||
| 127 | If <tt>host</tt> was given, returns a numerically-indexed table with the | ||
| 128 | canonical host name found for each address the resolver returns for | ||
| 129 | <tt>host</tt>. If <tt>service</tt> was also given, the canonical service | ||
| 130 | name is returned as an additional value; if only <tt>service</tt> was | ||
| 131 | given, its canonical name is returned by itself. In case of error, the | ||
| 132 | function returns <b><tt>nil</tt></b> followed by an error message. | ||
| 133 | </p> | ||
| 134 | |||
| 109 | <!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 135 | <!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 110 | 136 | ||
| 111 | <p class="name" id="gethostname"> | 137 | <p class="name" id="gethostname"> |
diff --git a/docs/http.html b/docs/http.html index c6423ba..316cd2e 100644 --- a/docs/http.html +++ b/docs/http.html | |||
| @@ -114,7 +114,11 @@ the HTTP module: | |||
| 114 | <ul> | 114 | <ul> |
| 115 | <li> <tt>PROXY</tt>: default proxy used for connections;</li> | 115 | <li> <tt>PROXY</tt>: default proxy used for connections;</li> |
| 116 | <li> <tt>TIMEOUT</tt>: sets the timeout for all I/O operations;</li> | 116 | <li> <tt>TIMEOUT</tt>: sets the timeout for all I/O operations;</li> |
| 117 | <li> <tt>USERAGENT</tt>: default user agent reported to server.</li> | 117 | <li> <tt>USERAGENT</tt>: default user agent reported to server;</li> |
| 118 | <li> <tt>MAXHEADERLINE</tt>: maximum length, in bytes, of a single response | ||
| 119 | header line. Defaults to 8192;</li> | ||
| 120 | <li> <tt>MAXHEADERSIZE</tt>: maximum total size, in bytes, of all response | ||
| 121 | header lines combined. Defaults to 65536.</li> | ||
| 118 | </ul> | 122 | </ul> |
| 119 | 123 | ||
| 120 | <p class="note"> | 124 | <p class="note"> |
| @@ -183,7 +187,8 @@ pump step function used to move data. | |||
| 183 | Defaults to the LTN12 <tt>pump.step</tt> function.</li> | 187 | Defaults to the LTN12 <tt>pump.step</tt> function.</li> |
| 184 | <li><tt>proxy</tt>: The URL of a proxy server to use. Defaults to no proxy;</li> | 188 | <li><tt>proxy</tt>: The URL of a proxy server to use. Defaults to no proxy;</li> |
| 185 | <li><tt>redirect</tt>: Set to <tt><b>false</b></tt> to prevent the | 189 | <li><tt>redirect</tt>: Set to <tt><b>false</b></tt> to prevent the |
| 186 | function from automatically following 301 or 302 server redirect messages;</li> | 190 | function from automatically following 301, 302, 303, 307 or 308 server |
| 191 | redirect messages;</li> | ||
| 187 | <li><tt>create</tt>: An optional function to be used instead of | 192 | <li><tt>create</tt>: An optional function to be used instead of |
| 188 | <a href="tcp.html#socket.tcp"><tt>socket.tcp</tt></a> when the communications socket is created.</li> | 193 | <a href="tcp.html#socket.tcp"><tt>socket.tcp</tt></a> when the communications socket is created.</li> |
| 189 | <li><tt>maxredirects</tt>: An optional number specifying the maximum number of | 194 | <li><tt>maxredirects</tt>: An optional number specifying the maximum number of |
diff --git a/docs/index.html b/docs/index.html index 3341f8d..7a22dd6 100644 --- a/docs/index.html +++ b/docs/index.html | |||
| @@ -67,6 +67,8 @@ In addition, you will find that the | |||
| 67 | (anything you could possible want to do with one) and | 67 | (anything you could possible want to do with one) and |
| 68 | <a href="ltn12.html">LTN12</a> | 68 | <a href="ltn12.html">LTN12</a> |
| 69 | (filters, sinks, sources and pumps) modules can be very handy. | 69 | (filters, sinks, sources and pumps) modules can be very handy. |
| 70 | On Unix-like platforms, dedicated <a href="unix.html">Unix domain socket</a> | ||
| 71 | and <a href="serial.html">serial port</a> modules are also available. | ||
| 70 | </p> | 72 | </p> |
| 71 | 73 | ||
| 72 | <p> | 74 | <p> |
diff --git a/docs/installation.html b/docs/installation.html index b56f50f..bdc8b1d 100644 --- a/docs/installation.html +++ b/docs/installation.html | |||
| @@ -57,7 +57,7 @@ luarocks install luasocket | |||
| 57 | print(socket._VERSION) | 57 | print(socket._VERSION) |
| 58 | </code></pre> | 58 | </code></pre> |
| 59 | 59 | ||
| 60 | <p>If you see output like <strong>LuaSocket 3.0</strong>, the installation was successful.</p> | 60 | <p>If you see output like <strong>LuaSocket 3.1.0</strong>, the installation was successful.</p> |
| 61 | 61 | ||
| 62 | <h3>More Information</h3> | 62 | <h3>More Information</h3> |
| 63 | <p>For more details, visit the <a href="https://github.com/lunarmodules/luasocket" target="_blank">LuaSocket GitHub repository</a>.</p> | 63 | <p>For more details, visit the <a href="https://github.com/lunarmodules/luasocket" target="_blank">LuaSocket GitHub repository</a>.</p> |
diff --git a/docs/introduction.html b/docs/introduction.html index 51443a0..bc0d535 100644 --- a/docs/introduction.html +++ b/docs/introduction.html | |||
| @@ -304,7 +304,10 @@ io.write(assert(udp:receive())) | |||
| 304 | <p> Although not covered in the introduction, LuaSocket offers | 304 | <p> Although not covered in the introduction, LuaSocket offers |
| 305 | much more than TCP and UDP functionality. As the library | 305 | much more than TCP and UDP functionality. As the library |
| 306 | evolved, support for <a href=http.html>HTTP</a>, <a href=ftp.html>FTP</a>, | 306 | evolved, support for <a href=http.html>HTTP</a>, <a href=ftp.html>FTP</a>, |
| 307 | and <a href=smtp.html>SMTP</a> were built on top of these. These modules | 307 | and <a href=smtp.html>SMTP</a> were built on top of these. On Unix-like |
| 308 | platforms, the library also ships separate <a href=unix.html>Unix domain | ||
| 309 | socket</a> and <a href=serial.html>serial port</a> modules, requirable as | ||
| 310 | <tt>socket.unix</tt> and <tt>socket.serial</tt>. These modules | ||
| 308 | and many others are covered by the <a href=reference.html>reference manual</a>. | 311 | and many others are covered by the <a href=reference.html>reference manual</a>. |
| 309 | </p> | 312 | </p> |
| 310 | 313 | ||
diff --git a/docs/ltn12.html b/docs/ltn12.html index 30bc564..76b3984 100644 --- a/docs/ltn12.html +++ b/docs/ltn12.html | |||
| @@ -55,6 +55,20 @@ To obtain the <tt>ltn12</tt> namespace, run: | |||
| 55 | local ltn12 = require("ltn12") | 55 | local ltn12 = require("ltn12") |
| 56 | </pre> | 56 | </pre> |
| 57 | 57 | ||
| 58 | <!-- BLOCKSIZE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 59 | |||
| 60 | <p class="name" id="BLOCKSIZE"> | ||
| 61 | ltn12.<b>BLOCKSIZE</b> | ||
| 62 | </p> | ||
| 63 | |||
| 64 | <p class="description"> | ||
| 65 | The default chunk size, in bytes, used internally by the built-in sources | ||
| 66 | and sinks (e.g. <a href="#source.string"><tt>source.string</tt></a>, | ||
| 67 | <a href="#source.file"><tt>source.file</tt></a>) when they have no more | ||
| 68 | natural chunk size of their own. Defaults to 2048. Changing it affects | ||
| 69 | only sources/sinks created after the change. | ||
| 70 | </p> | ||
| 71 | |||
| 58 | <!-- filters ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 72 | <!-- filters ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 59 | 73 | ||
| 60 | <h3 id="filter">Filters</h3> | 74 | <h3 id="filter">Filters</h3> |
| @@ -415,6 +429,30 @@ ltn12.source.<b>table(</b>table<b>)</b> | |||
| 415 | Creates and returns a source that produces the numerically-indexed values of a <tt>table</tt> successively beginning at 1. The source returns nil (end-of-stream) whenever a nil value is produced by the current index, which proceeds forward regardless. | 429 | Creates and returns a source that produces the numerically-indexed values of a <tt>table</tt> successively beginning at 1. The source returns nil (end-of-stream) whenever a nil value is produced by the current index, which proceeds forward regardless. |
| 416 | </p> | 430 | </p> |
| 417 | 431 | ||
| 432 | <!-- rewind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 433 | |||
| 434 | <p class="name" id="source.rewind"> | ||
| 435 | ltn12.source.<b>rewind(</b>source<b>)</b> | ||
| 436 | </p> | ||
| 437 | |||
| 438 | <p class="description"> | ||
| 439 | Wraps a <em>fancy</em> <tt>source</tt> to add chunk pushback, so previously | ||
| 440 | produced chunks can be fed back in for a later read to consume again. | ||
| 441 | </p> | ||
| 442 | |||
| 443 | <p class="parameters"> | ||
| 444 | <tt>Source</tt> is the fancy source being wrapped. | ||
| 445 | </p> | ||
| 446 | |||
| 447 | <p class="return"> | ||
| 448 | The function returns a new fancy source. Calling it with no arguments reads | ||
| 449 | the next chunk as usual: any chunks previously pushed back are returned | ||
| 450 | first (most recently pushed back, first), and once none remain it falls | ||
| 451 | through to <tt>source</tt>. Calling it <em>with</em> a chunk argument does | ||
| 452 | not read anything: it pushes that chunk back onto the internal stack for a | ||
| 453 | future no-argument call to return. | ||
| 454 | </p> | ||
| 455 | |||
| 418 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 456 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 419 | 457 | ||
| 420 | <div class="footer"> | 458 | <div class="footer"> |
diff --git a/docs/reference.html b/docs/reference.html index 2bc5f78..7425716 100644 --- a/docs/reference.html +++ b/docs/reference.html | |||
| @@ -43,6 +43,7 @@ Support, Manual"> | |||
| 43 | <a href="dns.html">DNS (in socket)</a> | 43 | <a href="dns.html">DNS (in socket)</a> |
| 44 | <blockquote> | 44 | <blockquote> |
| 45 | <a href="dns.html#getaddrinfo">getaddrinfo</a>, | 45 | <a href="dns.html#getaddrinfo">getaddrinfo</a>, |
| 46 | <a href="dns.html#getnameinfo">getnameinfo</a>, | ||
| 46 | <a href="dns.html#gethostname">gethostname</a>, | 47 | <a href="dns.html#gethostname">gethostname</a>, |
| 47 | <a href="dns.html#tohostname">tohostname</a>, | 48 | <a href="dns.html#tohostname">tohostname</a>, |
| 48 | <a href="dns.html#toip">toip</a>. | 49 | <a href="dns.html#toip">toip</a>. |
| @@ -73,6 +74,9 @@ Support, Manual"> | |||
| 73 | <blockquote> | 74 | <blockquote> |
| 74 | <a href="ltn12.html">LTN12</a> | 75 | <a href="ltn12.html">LTN12</a> |
| 75 | <blockquote> | 76 | <blockquote> |
| 77 | <a href="ltn12.html#BLOCKSIZE">BLOCKSIZE</a>. | ||
| 78 | </blockquote> | ||
| 79 | <blockquote> | ||
| 76 | <a href="ltn12.html#filter">filter</a>: | 80 | <a href="ltn12.html#filter">filter</a>: |
| 77 | <a href="ltn12.html#filter.chain">chain</a>, | 81 | <a href="ltn12.html#filter.chain">chain</a>, |
| 78 | <a href="ltn12.html#filter.cycle">cycle</a>. | 82 | <a href="ltn12.html#filter.cycle">cycle</a>. |
| @@ -98,6 +102,7 @@ Support, Manual"> | |||
| 98 | <a href="ltn12.html#source.empty">empty</a>, | 102 | <a href="ltn12.html#source.empty">empty</a>, |
| 99 | <a href="ltn12.html#source.error">error</a>, | 103 | <a href="ltn12.html#source.error">error</a>, |
| 100 | <a href="ltn12.html#source.file">file</a>, | 104 | <a href="ltn12.html#source.file">file</a>, |
| 105 | <a href="ltn12.html#source.rewind">rewind</a>, | ||
| 101 | <a href="ltn12.html#source.simplify">simplify</a>, | 106 | <a href="ltn12.html#source.simplify">simplify</a>, |
| 102 | <a href="ltn12.html#source.string">string</a>, | 107 | <a href="ltn12.html#source.string">string</a>, |
| 103 | <a href="ltn12.html#source.table">table</a>. | 108 | <a href="ltn12.html#source.table">table</a>. |
| @@ -129,6 +134,23 @@ Support, Manual"> | |||
| 129 | </blockquote> | 134 | </blockquote> |
| 130 | </blockquote> | 135 | </blockquote> |
| 131 | 136 | ||
| 137 | <!-- serial +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 138 | |||
| 139 | <blockquote> | ||
| 140 | <a href="serial.html">Serial</a> | ||
| 141 | <blockquote> | ||
| 142 | <a href="serial.html#close">close</a>, | ||
| 143 | <a href="serial.html#getfd">getfd</a>, | ||
| 144 | <a href="serial.html#getstats">getstats</a>, | ||
| 145 | <a href="serial.html#receive">receive</a>, | ||
| 146 | <a href="serial.html#send">send</a>, | ||
| 147 | <a href="serial.html#setfd">setfd</a>, | ||
| 148 | <a href="serial.html#setstats">setstats</a>, | ||
| 149 | <a href="serial.html#settimeout">settimeout</a>, | ||
| 150 | <a href="serial.html#socket.serial">socket.serial</a>. | ||
| 151 | </blockquote> | ||
| 152 | </blockquote> | ||
| 153 | |||
| 132 | <!-- smtp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 154 | <!-- smtp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 133 | 155 | ||
| 134 | <blockquote> | 156 | <blockquote> |
| @@ -153,6 +175,7 @@ Support, Manual"> | |||
| 153 | <a href="dns.html#dns">dns</a>, | 175 | <a href="dns.html#dns">dns</a>, |
| 154 | <a href="socket.html#gettime">gettime</a>, | 176 | <a href="socket.html#gettime">gettime</a>, |
| 155 | <a href="socket.html#headers.canonic">headers.canonic</a>, | 177 | <a href="socket.html#headers.canonic">headers.canonic</a>, |
| 178 | <a href="socket.html#headers.setcanonic">headers.setcanonic</a>, | ||
| 156 | <a href="socket.html#newtry">newtry</a>, | 179 | <a href="socket.html#newtry">newtry</a>, |
| 157 | <a href="socket.html#protect">protect</a>, | 180 | <a href="socket.html#protect">protect</a>, |
| 158 | <a href="socket.html#select">select</a>, | 181 | <a href="socket.html#select">select</a>, |
| @@ -183,6 +206,7 @@ Support, Manual"> | |||
| 183 | <a href="tcp.html#close">close</a>, | 206 | <a href="tcp.html#close">close</a>, |
| 184 | <a href="tcp.html#connect">connect</a>, | 207 | <a href="tcp.html#connect">connect</a>, |
| 185 | <a href="tcp.html#dirty">dirty</a>, | 208 | <a href="tcp.html#dirty">dirty</a>, |
| 209 | <a href="tcp.html#getfamily">getfamily</a>, | ||
| 186 | <a href="tcp.html#getfd">getfd</a>, | 210 | <a href="tcp.html#getfd">getfd</a>, |
| 187 | <a href="tcp.html#getoption">getoption</a>, | 211 | <a href="tcp.html#getoption">getoption</a>, |
| 188 | <a href="tcp.html#getpeername">getpeername</a>, | 212 | <a href="tcp.html#getpeername">getpeername</a>, |
| @@ -194,6 +218,8 @@ Support, Manual"> | |||
| 194 | <a href="tcp.html#send">send</a>, | 218 | <a href="tcp.html#send">send</a>, |
| 195 | <a href="tcp.html#setfd">setfd</a>, | 219 | <a href="tcp.html#setfd">setfd</a>, |
| 196 | <a href="tcp.html#setoption">setoption</a>, | 220 | <a href="tcp.html#setoption">setoption</a>, |
| 221 | <a href="tcp.html#setpeername">setpeername</a>, | ||
| 222 | <a href="tcp.html#setsockname">setsockname</a>, | ||
| 197 | <a href="tcp.html#setstats">setstats</a>, | 223 | <a href="tcp.html#setstats">setstats</a>, |
| 198 | <a href="tcp.html#settimeout">settimeout</a>, | 224 | <a href="tcp.html#settimeout">settimeout</a>, |
| 199 | <a href="tcp.html#shutdown">shutdown</a>. | 225 | <a href="tcp.html#shutdown">shutdown</a>. |
| @@ -206,6 +232,9 @@ Support, Manual"> | |||
| 206 | <a href="udp.html">UDP (in socket)</a> | 232 | <a href="udp.html">UDP (in socket)</a> |
| 207 | <blockquote> | 233 | <blockquote> |
| 208 | <a href="udp.html#close">close</a>, | 234 | <a href="udp.html#close">close</a>, |
| 235 | <a href="udp.html#dirty">dirty</a>, | ||
| 236 | <a href="udp.html#getfamily">getfamily</a>, | ||
| 237 | <a href="udp.html#getfd">getfd</a>, | ||
| 209 | <a href="udp.html#getoption">getoption</a>, | 238 | <a href="udp.html#getoption">getoption</a>, |
| 210 | <a href="udp.html#getpeername">getpeername</a>, | 239 | <a href="udp.html#getpeername">getpeername</a>, |
| 211 | <a href="udp.html#getsockname">getsockname</a>, | 240 | <a href="udp.html#getsockname">getsockname</a>, |
| @@ -214,6 +243,7 @@ Support, Manual"> | |||
| 214 | <a href="udp.html#receivefrom">receivefrom</a>, | 243 | <a href="udp.html#receivefrom">receivefrom</a>, |
| 215 | <a href="udp.html#send">send</a>, | 244 | <a href="udp.html#send">send</a>, |
| 216 | <a href="udp.html#sendto">sendto</a>, | 245 | <a href="udp.html#sendto">sendto</a>, |
| 246 | <a href="udp.html#setfd">setfd</a>, | ||
| 217 | <a href="udp.html#setpeername">setpeername</a>, | 247 | <a href="udp.html#setpeername">setpeername</a>, |
| 218 | <a href="udp.html#setsockname">setsockname</a>, | 248 | <a href="udp.html#setsockname">setsockname</a>, |
| 219 | <a href="udp.html#setoption">setoption</a>, | 249 | <a href="udp.html#setoption">setoption</a>, |
| @@ -221,6 +251,48 @@ Support, Manual"> | |||
| 221 | </blockquote> | 251 | </blockquote> |
| 222 | </blockquote> | 252 | </blockquote> |
| 223 | 253 | ||
| 254 | <!-- unix +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 255 | |||
| 256 | <blockquote> | ||
| 257 | <a href="unix.html">Unix</a> | ||
| 258 | <blockquote> | ||
| 259 | <a href="unix.html#socket.unix.stream">socket.unix.stream</a>: | ||
| 260 | <a href="unix.html#stream.accept">accept</a>, | ||
| 261 | <a href="unix.html#stream.bind">bind</a>, | ||
| 262 | <a href="unix.html#stream.close">close</a>, | ||
| 263 | <a href="unix.html#stream.connect">connect</a>, | ||
| 264 | <a href="unix.html#stream.dirty">dirty</a>, | ||
| 265 | <a href="unix.html#stream.getfd">getfd</a>, | ||
| 266 | <a href="unix.html#stream.getsockname">getsockname</a>, | ||
| 267 | <a href="unix.html#stream.getstats">getstats</a>, | ||
| 268 | <a href="unix.html#stream.listen">listen</a>, | ||
| 269 | <a href="unix.html#stream.receive">receive</a>, | ||
| 270 | <a href="unix.html#stream.send">send</a>, | ||
| 271 | <a href="unix.html#stream.setfd">setfd</a>, | ||
| 272 | <a href="unix.html#stream.setoption">setoption</a>, | ||
| 273 | <a href="unix.html#stream.setstats">setstats</a>, | ||
| 274 | <a href="unix.html#stream.settimeout">settimeout</a>, | ||
| 275 | <a href="unix.html#stream.shutdown">shutdown</a>. | ||
| 276 | </blockquote> | ||
| 277 | <blockquote> | ||
| 278 | <a href="unix.html#socket.unix.dgram">socket.unix.dgram</a>: | ||
| 279 | <a href="unix.html#dgram.bind">bind</a>, | ||
| 280 | <a href="unix.html#dgram.close">close</a>, | ||
| 281 | <a href="unix.html#dgram.connect">connect</a>, | ||
| 282 | <a href="unix.html#dgram.dirty">dirty</a>, | ||
| 283 | <a href="unix.html#dgram.getfd">getfd</a>, | ||
| 284 | <a href="unix.html#dgram.getsockname">getsockname</a>, | ||
| 285 | <a href="unix.html#dgram.gettimeout">gettimeout</a>, | ||
| 286 | <a href="unix.html#dgram.receive">receive</a>, | ||
| 287 | <a href="unix.html#dgram.receivefrom">receivefrom</a>, | ||
| 288 | <a href="unix.html#dgram.send">send</a>, | ||
| 289 | <a href="unix.html#dgram.sendto">sendto</a>, | ||
| 290 | <a href="unix.html#dgram.setfd">setfd</a>, | ||
| 291 | <a href="unix.html#dgram.setoption">setoption</a>, | ||
| 292 | <a href="unix.html#dgram.settimeout">settimeout</a>. | ||
| 293 | </blockquote> | ||
| 294 | </blockquote> | ||
| 295 | |||
| 224 | <!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 296 | <!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 225 | 297 | ||
| 226 | <blockquote> | 298 | <blockquote> |
diff --git a/docs/serial.html b/docs/serial.html new file mode 100644 index 0000000..8e123b0 --- /dev/null +++ b/docs/serial.html | |||
| @@ -0,0 +1,308 @@ | |||
| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | ||
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> | ||
| 3 | <html> | ||
| 4 | |||
| 5 | <head> | ||
| 6 | <meta name="description" content="LuaSocket: Serial port support"> | ||
| 7 | <meta name="keywords" content="Lua, LuaSocket, Serial, Port, TTY, Library, Support"> | ||
| 8 | <title>LuaSocket: Serial port support</title> | ||
| 9 | <link rel="stylesheet" href="reference.css" type="text/css"> | ||
| 10 | </head> | ||
| 11 | |||
| 12 | <body> | ||
| 13 | |||
| 14 | <!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 15 | |||
| 16 | <div class="header"> | ||
| 17 | <hr> | ||
| 18 | <center> | ||
| 19 | <table summary="LuaSocket logo"> | ||
| 20 | <tr><td align="center"><a href="http://www.lua.org"> | ||
| 21 | <img width="128" height="128" border="0" alt="LuaSocket" src="luasocket.png"> | ||
| 22 | </a></td></tr> | ||
| 23 | <tr><td align="center" valign="top">Network support for the Lua language | ||
| 24 | </td></tr> | ||
| 25 | </table> | ||
| 26 | <p class="bar"> | ||
| 27 | <a href="index.html">home</a> · | ||
| 28 | <a href="index.html#download">download</a> · | ||
| 29 | <a href="installation.html">installation</a> · | ||
| 30 | <a href="introduction.html">introduction</a> · | ||
| 31 | <a href="reference.html">reference</a> | ||
| 32 | </p> | ||
| 33 | </center> | ||
| 34 | <hr> | ||
| 35 | </div> | ||
| 36 | |||
| 37 | <!-- serial +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 38 | |||
| 39 | <h2 id="serial">Serial port support</h2> | ||
| 40 | |||
| 41 | <p> | ||
| 42 | The <tt>socket.serial</tt> module opens a serial device (e.g. | ||
| 43 | <tt>/dev/ttyUSB0</tt>) and exposes it through the same buffered, | ||
| 44 | timeout-aware <tt>send</tt>/<tt>receive</tt> interface used by | ||
| 45 | <a href="tcp.html">TCP</a> and <a href="unix.html">Unix domain</a> | ||
| 46 | stream objects. | ||
| 47 | </p> | ||
| 48 | |||
| 49 | <p class="note"> | ||
| 50 | Note: This module is only built on Unix-like platforms (Linux, macOS, | ||
| 51 | BSD, Haiku). It is not available on Windows. | ||
| 52 | </p> | ||
| 53 | |||
| 54 | <p> | ||
| 55 | Serial port support is a separate module that must be required | ||
| 56 | explicitly. Unlike most other LuaSocket modules, it returns a | ||
| 57 | <em>function</em> directly — the constructor — rather than a | ||
| 58 | table of functions: | ||
| 59 | </p> | ||
| 60 | |||
| 61 | <pre class="example"> | ||
| 62 | -- loads the socket.serial module; note this is the constructor itself | ||
| 63 | local serial_open = require("socket.serial") | ||
| 64 | |||
| 65 | -- open the device | ||
| 66 | local port = assert(serial_open("/dev/ttyUSB0")) | ||
| 67 | port:settimeout(1) | ||
| 68 | assert(port:send("AT\r\n")) | ||
| 69 | print(port:receive()) | ||
| 70 | port:close() | ||
| 71 | </pre> | ||
| 72 | |||
| 73 | <p class="note"> | ||
| 74 | Note: <b>There is currently no API to configure the serial line itself | ||
| 75 | — baud rate, parity, data/stop bits or flow control.</b> The device | ||
| 76 | is opened non-blocking with whatever settings the OS driver or a prior | ||
| 77 | external configuration (e.g. <tt>stty</tt>) left it in. This is a known | ||
| 78 | current limitation of the module, not a deliberate protection against | ||
| 79 | misuse; a future version may add a <tt>setoption</tt>-style API for these | ||
| 80 | settings the way <a href="tcp.html#setoption"><tt>tcp:setoption</tt></a> | ||
| 81 | does for TCP. | ||
| 82 | </p> | ||
| 83 | |||
| 84 | <p> | ||
| 85 | Until such an API exists, the workaround is to configure the line with | ||
| 86 | the platform's own <tt>stty</tt> utility (via <tt>os.execute</tt>) | ||
| 87 | <em>before</em> opening the device with <tt>socket.serial</tt>: | ||
| 88 | </p> | ||
| 89 | |||
| 90 | <pre class="example"> | ||
| 91 | local serial_open = require("socket.serial") | ||
| 92 | |||
| 93 | local dev = "/dev/ttyUSB0" | ||
| 94 | |||
| 95 | -- Linux: stty -F <device> ... | ||
| 96 | local ok = os.execute(string.format( | ||
| 97 | "stty -F %s 115200 cs8 -cstopb -parenb raw -echo", dev)) | ||
| 98 | |||
| 99 | -- macOS/BSD use -f instead of -F: | ||
| 100 | -- os.execute(string.format("stty -f %s 115200 cs8 -cstopb -parenb raw -echo", dev)) | ||
| 101 | |||
| 102 | assert(ok, "failed to configure serial line with stty") | ||
| 103 | |||
| 104 | local port = assert(serial_open(dev)) | ||
| 105 | port:settimeout(1) | ||
| 106 | assert(port:send("AT\r\n")) | ||
| 107 | print(port:receive()) | ||
| 108 | port:close() | ||
| 109 | </pre> | ||
| 110 | |||
| 111 | <p class="note"> | ||
| 112 | Note: <tt>raw -echo</tt> puts the line in raw mode, which matters for | ||
| 113 | LuaSocket's framing: without it, the TTY driver applies its own line | ||
| 114 | editing/echo, which can interfere with <a href="#receive"><tt>receive</tt></a> | ||
| 115 | patterns and <a href="#send"><tt>send</tt></a> content. Adjust the | ||
| 116 | <tt>stty</tt> flags (baud rate, parity, stop bits, flow control) to match | ||
| 117 | your device; consult <tt>man stty</tt> for the full option set on your | ||
| 118 | platform, since flag names and defaults vary between Linux, macOS and the | ||
| 119 | BSDs. | ||
| 120 | </p> | ||
| 121 | |||
| 122 | <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 123 | |||
| 124 | <p class="name" id="close"> | ||
| 125 | port:<b>close()</b> | ||
| 126 | </p> | ||
| 127 | |||
| 128 | <p class="description"> | ||
| 129 | Closes a serial object. No further operations (except further calls to | ||
| 130 | <tt>close</tt>) are allowed on a closed object. | ||
| 131 | </p> | ||
| 132 | |||
| 133 | <p class="note"> | ||
| 134 | Note: Garbage-collected objects are automatically closed before | ||
| 135 | destruction. | ||
| 136 | </p> | ||
| 137 | |||
| 138 | <!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 139 | |||
| 140 | <p class="name" id="dirty"> | ||
| 141 | port:<b>dirty()</b> | ||
| 142 | </p> | ||
| 143 | |||
| 144 | <p class="description"> | ||
| 145 | Check the read buffer status. | ||
| 146 | </p> | ||
| 147 | |||
| 148 | <p class="return"> | ||
| 149 | Returns <tt>true</tt> if there is any data in the read buffer, | ||
| 150 | <tt>false</tt> otherwise. | ||
| 151 | </p> | ||
| 152 | |||
| 153 | <p class="note"> | ||
| 154 | Note: <b>This is an internal method, use at your own risk.</b> | ||
| 155 | </p> | ||
| 156 | |||
| 157 | <!-- getfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 158 | |||
| 159 | <p class="name" id="getfd"> | ||
| 160 | port:<b>getfd()</b> | ||
| 161 | </p> | ||
| 162 | |||
| 163 | <p class="description"> | ||
| 164 | Returns the underlying file descriptor associated to the object. | ||
| 165 | </p> | ||
| 166 | |||
| 167 | <p class="return"> | ||
| 168 | The descriptor. | ||
| 169 | </p> | ||
| 170 | |||
| 171 | <p class="note"> | ||
| 172 | Note: <b>This is an internal method. Unlikely to be portable. Use at your | ||
| 173 | own risk.</b> | ||
| 174 | </p> | ||
| 175 | |||
| 176 | <!-- getstats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 177 | |||
| 178 | <p class="name" id="getstats"> | ||
| 179 | port:<b>getstats()</b> | ||
| 180 | </p> | ||
| 181 | |||
| 182 | <p class="description"> | ||
| 183 | Returns accounting information on the port, useful for throttling of | ||
| 184 | bandwidth. Works exactly like | ||
| 185 | <a href="tcp.html#getstats"><tt>tcp:getstats</tt></a>. | ||
| 186 | </p> | ||
| 187 | |||
| 188 | <p class="return"> | ||
| 189 | The method returns the number of bytes received, the number of bytes | ||
| 190 | sent, and the age of the object in seconds. | ||
| 191 | </p> | ||
| 192 | |||
| 193 | <!-- receive +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 194 | |||
| 195 | <p class="name" id="receive"> | ||
| 196 | port:<b>receive(</b>[pattern [, prefix [, maxsize]]]<b>)</b> | ||
| 197 | </p> | ||
| 198 | |||
| 199 | <p class="description"> | ||
| 200 | Reads data from the serial port, according to the specified <em>read | ||
| 201 | pattern</em>. Works exactly like | ||
| 202 | <a href="tcp.html#receive"><tt>tcp:receive</tt></a>, including the | ||
| 203 | <tt>*a</tt>/<tt>*l</tt>/<tt>number</tt> patterns and the | ||
| 204 | <tt>prefix</tt>/<tt>maxsize</tt> parameters. | ||
| 205 | </p> | ||
| 206 | |||
| 207 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 208 | |||
| 209 | <p class="name" id="send"> | ||
| 210 | port:<b>send(</b>data [, i [, j]]<b>)</b> | ||
| 211 | </p> | ||
| 212 | |||
| 213 | <p class="description"> | ||
| 214 | Sends <tt>data</tt> through the serial port. Works exactly like | ||
| 215 | <a href="tcp.html#send"><tt>tcp:send</tt></a>, including the optional | ||
| 216 | <tt>i</tt>/<tt>j</tt> substring selection. | ||
| 217 | </p> | ||
| 218 | |||
| 219 | <!-- setfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 220 | |||
| 221 | <p class="name" id="setfd"> | ||
| 222 | port:<b>setfd(</b>fd<b>)</b> | ||
| 223 | </p> | ||
| 224 | |||
| 225 | <p class="description"> | ||
| 226 | Sets the underlying file descriptor associated to the object. The current | ||
| 227 | one is simply replaced, not closed, and no other change to the object | ||
| 228 | state is made. | ||
| 229 | </p> | ||
| 230 | |||
| 231 | <p class="return"> | ||
| 232 | No return value. | ||
| 233 | </p> | ||
| 234 | |||
| 235 | <p class="note"> | ||
| 236 | Note: <b>This is an internal method. Unlikely to be portable. Use at your | ||
| 237 | own risk.</b> | ||
| 238 | </p> | ||
| 239 | |||
| 240 | <!-- setstats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 241 | |||
| 242 | <p class="name" id="setstats"> | ||
| 243 | port:<b>setstats(</b>received, sent, age<b>)</b> | ||
| 244 | </p> | ||
| 245 | |||
| 246 | <p class="description"> | ||
| 247 | Resets accounting information on the port, useful for throttling of | ||
| 248 | bandwidth. Works exactly like | ||
| 249 | <a href="tcp.html#setstats"><tt>tcp:setstats</tt></a>. | ||
| 250 | </p> | ||
| 251 | |||
| 252 | <p class="return"> | ||
| 253 | The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. | ||
| 254 | </p> | ||
| 255 | |||
| 256 | <!-- settimeout ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 257 | |||
| 258 | <p class="name" id="settimeout"> | ||
| 259 | port:<b>settimeout(</b>value [, mode]<b>)</b> | ||
| 260 | </p> | ||
| 261 | |||
| 262 | <p class="description"> | ||
| 263 | Changes the timeout values for the object. Works exactly like | ||
| 264 | <a href="tcp.html#settimeout"><tt>tcp:settimeout</tt></a>, including the | ||
| 265 | '<tt>b</tt>' (block) and '<tt>t</tt>' (total) modes. | ||
| 266 | </p> | ||
| 267 | |||
| 268 | <!-- socket.serial +++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 269 | |||
| 270 | <p class="name" id="socket.serial"> | ||
| 271 | serial_open(<b>path</b>) | ||
| 272 | </p> | ||
| 273 | |||
| 274 | <p class="description"> | ||
| 275 | Opens the serial device at <tt>path</tt> and returns a serial object. | ||
| 276 | This is the value returned directly by <tt>require("socket.serial")</tt> | ||
| 277 | — there is no separate module table to index into, unlike | ||
| 278 | <tt>socket.unix.stream()</tt> or <tt>socket.tcp()</tt>. | ||
| 279 | </p> | ||
| 280 | |||
| 281 | <p class="parameters"> | ||
| 282 | <tt>Path</tt> is a string with the device path (e.g. | ||
| 283 | <tt>"/dev/ttyUSB0"</tt> or <tt>"/dev/ttyS0"</tt>). | ||
| 284 | </p> | ||
| 285 | |||
| 286 | <p class="return"> | ||
| 287 | In case of success, a new serial object is returned. In case of error, | ||
| 288 | the function returns <b><tt>nil</tt></b>, followed by an error message, | ||
| 289 | followed by the numeric <tt>errno</tt> value. | ||
| 290 | </p> | ||
| 291 | |||
| 292 | <!-- footer ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 293 | |||
| 294 | <div class="footer"> | ||
| 295 | <hr> | ||
| 296 | <center> | ||
| 297 | <p class="bar"> | ||
| 298 | <a href="index.html">home</a> · | ||
| 299 | <a href="index.html#download">download</a> · | ||
| 300 | <a href="installation.html">installation</a> · | ||
| 301 | <a href="introduction.html">introduction</a> · | ||
| 302 | <a href="reference.html">reference</a> | ||
| 303 | </p> | ||
| 304 | </center> | ||
| 305 | </div> | ||
| 306 | |||
| 307 | </body> | ||
| 308 | </html> | ||
diff --git a/docs/socket.html b/docs/socket.html index 570f6d5..de43135 100644 --- a/docs/socket.html +++ b/docs/socket.html | |||
| @@ -51,6 +51,14 @@ To obtain the <tt>socket</tt> namespace, run: | |||
| 51 | local socket = require("socket") | 51 | local socket = require("socket") |
| 52 | </pre> | 52 | </pre> |
| 53 | 53 | ||
| 54 | <p> | ||
| 55 | Two related transports are shipped as separate modules, loaded on demand | ||
| 56 | with their own <tt>require</tt> call: <a href="unix.html">Unix domain | ||
| 57 | sockets</a> (<tt>require("socket.unix")</tt>) and | ||
| 58 | <a href="serial.html">serial ports</a> (<tt>require("socket.serial")</tt>). | ||
| 59 | Both are only built on Unix-like platforms. | ||
| 60 | </p> | ||
| 61 | |||
| 54 | <!-- headers.canonic ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 62 | <!-- headers.canonic ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 55 | 63 | ||
| 56 | <p class="name" id="headers.canonic"> | 64 | <p class="name" id="headers.canonic"> |
| @@ -94,6 +102,27 @@ local headers = require("socket.headers") | |||
| 94 | headers.setcanonic("X-Request-ID") | 102 | headers.setcanonic("X-Request-ID") |
| 95 | </pre> | 103 | </pre> |
| 96 | 104 | ||
| 105 | <!-- headers.setcanonic +++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 106 | |||
| 107 | <p class="name" id="headers.setcanonic"> | ||
| 108 | socket.headers.<b>setcanonic(</b>name<b>)</b> | ||
| 109 | </p> | ||
| 110 | |||
| 111 | <p class="description"> | ||
| 112 | Registers a custom canonic capitalization for a header field name in | ||
| 113 | <a href="#headers.canonic"><tt>socket.headers.canonic</tt></a>, for use | ||
| 114 | when the automatic capitalize-first-letter-of-each-word rule would not | ||
| 115 | reproduce it (e.g. an all-caps acronym). | ||
| 116 | </p> | ||
| 117 | |||
| 118 | <p class="parameters"> | ||
| 119 | <tt>Name</tt> is a string with the header field name in its desired | ||
| 120 | canonic capitalization (e.g. <tt>"X-Request-ID"</tt>). | ||
| 121 | </p> | ||
| 122 | |||
| 123 | <p class="return"> | ||
| 124 | No return value. | ||
| 125 | </p> | ||
| 97 | 126 | ||
| 98 | <!-- bind ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 127 | <!-- bind ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 99 | 128 | ||
diff --git a/docs/tcp.html b/docs/tcp.html index 715d28f..580bdcf 100644 --- a/docs/tcp.html +++ b/docs/tcp.html | |||
| @@ -196,6 +196,25 @@ Note: <b>This is an internal method, use at your own risk.</b> | |||
| 196 | </p> | 196 | </p> |
| 197 | 197 | ||
| 198 | 198 | ||
| 199 | <!-- getfamily +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 200 | |||
| 201 | <p class="name" id="getfamily"> | ||
| 202 | master:<b>getfamily()</b><br> | ||
| 203 | client:<b>getfamily()</b><br> | ||
| 204 | server:<b>getfamily()</b> | ||
| 205 | </p> | ||
| 206 | |||
| 207 | <p class="description"> | ||
| 208 | Returns the family of the underlying socket, as chosen when the object was | ||
| 209 | created by <a href="socket.html#connect"><tt>socket.tcp</tt></a>, | ||
| 210 | <a href="#socket.tcp4"><tt>socket.tcp4</tt></a> or | ||
| 211 | <a href="#socket.tcp6"><tt>socket.tcp6</tt></a>. | ||
| 212 | </p> | ||
| 213 | |||
| 214 | <p class="return"> | ||
| 215 | The string "<tt>inet4</tt>" or "<tt>inet6</tt>". | ||
| 216 | </p> | ||
| 217 | |||
| 199 | <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 218 | <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 200 | 219 | ||
| 201 | <p class="name" id="getfd"> | 220 | <p class="name" id="getfd"> |
| @@ -651,6 +670,30 @@ This is the default mode;</li> | |||
| 651 | This function returns 1. | 670 | This function returns 1. |
| 652 | </p> | 671 | </p> |
| 653 | 672 | ||
| 673 | <!-- setpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 674 | |||
| 675 | <p class="name" id="setpeername"> | ||
| 676 | master:<b>setpeername(</b>address, port<b>)</b> | ||
| 677 | </p> | ||
| 678 | |||
| 679 | <p class="description"> | ||
| 680 | Alias for <a href="#connect"><tt>connect</tt></a>, kept for naming symmetry | ||
| 681 | with <a href="udp.html#setpeername"><tt>udp:setpeername</tt></a> and with | ||
| 682 | <a href="#getpeername"><tt>getpeername</tt></a>. | ||
| 683 | </p> | ||
| 684 | |||
| 685 | <!-- setsockname +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 686 | |||
| 687 | <p class="name" id="setsockname"> | ||
| 688 | master:<b>setsockname(</b>address, port<b>)</b> | ||
| 689 | </p> | ||
| 690 | |||
| 691 | <p class="description"> | ||
| 692 | Alias for <a href="#bind"><tt>bind</tt></a>, kept for naming symmetry | ||
| 693 | with <a href="udp.html#setsockname"><tt>udp:setsockname</tt></a> and with | ||
| 694 | <a href="#getsockname"><tt>getsockname</tt></a>. | ||
| 695 | </p> | ||
| 696 | |||
| 654 | <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 697 | <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 655 | 698 | ||
| 656 | <p class="name" id="setfd"> | 699 | <p class="name" id="setfd"> |
diff --git a/docs/udp.html b/docs/udp.html index 8d807a4..d2c169a 100644 --- a/docs/udp.html +++ b/docs/udp.html | |||
| @@ -62,6 +62,66 @@ Garbage-collected objects are automatically closed before | |||
| 62 | destruction, though. | 62 | destruction, though. |
| 63 | </p> | 63 | </p> |
| 64 | 64 | ||
| 65 | <!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 66 | |||
| 67 | <p class="name" id="dirty"> | ||
| 68 | connected:<b>dirty()</b><br> | ||
| 69 | unconnected:<b>dirty()</b> | ||
| 70 | </p> | ||
| 71 | |||
| 72 | <p class="description"> | ||
| 73 | Check the read buffer status. | ||
| 74 | </p> | ||
| 75 | |||
| 76 | <p class="return"> | ||
| 77 | Returns <tt>false</tt>. UDP objects do not keep a read buffer, so this | ||
| 78 | always reports no buffered data. | ||
| 79 | </p> | ||
| 80 | |||
| 81 | <p class="note"> | ||
| 82 | Note: <b>This is an internal method, use at your own risk.</b> | ||
| 83 | </p> | ||
| 84 | |||
| 85 | <!-- getfamily +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 86 | |||
| 87 | <p class="name" id="getfamily"> | ||
| 88 | connected:<b>getfamily()</b><br> | ||
| 89 | unconnected:<b>getfamily()</b> | ||
| 90 | </p> | ||
| 91 | |||
| 92 | <p class="description"> | ||
| 93 | Returns the family of the underlying socket, as chosen when the object was | ||
| 94 | created by <a href="#socket.udp"><tt>socket.udp</tt></a>, | ||
| 95 | <a href="#socket.udp4"><tt>socket.udp4</tt></a> or | ||
| 96 | <a href="#socket.udp6"><tt>socket.udp6</tt></a>. | ||
| 97 | </p> | ||
| 98 | |||
| 99 | <p class="return"> | ||
| 100 | The string "<tt>inet4</tt>" or "<tt>inet6</tt>". | ||
| 101 | </p> | ||
| 102 | |||
| 103 | <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 104 | |||
| 105 | <p class="name" id="getfd"> | ||
| 106 | connected:<b>getfd()</b><br> | ||
| 107 | unconnected:<b>getfd()</b> | ||
| 108 | </p> | ||
| 109 | |||
| 110 | <p class="description"> | ||
| 111 | Returns the underling socket descriptor or handle associated to the object. | ||
| 112 | </p> | ||
| 113 | |||
| 114 | <p class="return"> | ||
| 115 | The descriptor or handle. In case the object has been closed, the return value | ||
| 116 | will be -1. For an invalid socket it will be <a href="socket.html#socketinvalid"> | ||
| 117 | <tt>_SOCKETINVALID</tt></a>. | ||
| 118 | </p> | ||
| 119 | |||
| 120 | <p class="note"> | ||
| 121 | Note: <b>This is an internal method. Unlikely to be | ||
| 122 | portable. Use at your own risk. </b> | ||
| 123 | </p> | ||
| 124 | |||
| 65 | <!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 125 | <!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 66 | 126 | ||
| 67 | <p class="name" id="getoption"> | 127 | <p class="name" id="getoption"> |
| @@ -321,8 +381,10 @@ Sets the unicast hop limit (the IPv6 equivalent of the IPv4 TTL) | |||
| 321 | for outgoing packets. | 381 | for outgoing packets. |
| 322 | Receives a number;</li> | 382 | Receives a number;</li> |
| 323 | <li> '<tt>ipv6-multicast-hops</tt>': | 383 | <li> '<tt>ipv6-multicast-hops</tt>': |
| 324 | Sets the hop limit for outgoing IPv6 multicast datagrams. | 384 | <b>Known limitation:</b> this option is currently wired to the same |
| 325 | Receives a number;</li> | 385 | underlying setting as <tt>ipv6-unicast-hops</tt> instead of a separate |
| 386 | multicast hop limit, so getting or setting one also gets or sets the | ||
| 387 | other. Receives a number;</li> | ||
| 326 | <li> '<tt>ipv6-multicast-loop</tt>': | 388 | <li> '<tt>ipv6-multicast-loop</tt>': |
| 327 | Specifies whether or not a copy of an outgoing IPv6 multicast | 389 | Specifies whether or not a copy of an outgoing IPv6 multicast |
| 328 | datagram is delivered to the sending host as long as it is a | 390 | datagram is delivered to the sending host as long as it is a |
| @@ -374,6 +436,28 @@ Note: The descriptions above come from the man pages. | |||
| 374 | </p> | 436 | </p> |
| 375 | 437 | ||
| 376 | 438 | ||
| 439 | <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 440 | |||
| 441 | <p class="name" id="setfd"> | ||
| 442 | connected:<b>setfd(</b>fd<b>)</b><br> | ||
| 443 | unconnected:<b>setfd(</b>fd<b>)</b> | ||
| 444 | </p> | ||
| 445 | |||
| 446 | <p class="description"> | ||
| 447 | Sets the underling socket descriptor or handle associated to the object. The current one | ||
| 448 | is simply replaced, not closed, and no other change to the object state is made. | ||
| 449 | To set it as invalid use <a href="socket.html#socketinvalid"><tt>_SOCKETINVALID</tt></a>. | ||
| 450 | </p> | ||
| 451 | |||
| 452 | <p class="return"> | ||
| 453 | No return value. | ||
| 454 | </p> | ||
| 455 | |||
| 456 | <p class="note"> | ||
| 457 | Note: <b>This is an internal method. Unlikely to be | ||
| 458 | portable. Use at your own risk. </b> | ||
| 459 | </p> | ||
| 460 | |||
| 377 | <!-- setpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 461 | <!-- setpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 378 | 462 | ||
| 379 | <p class="name" id="setpeername"> | 463 | <p class="name" id="setpeername"> |
diff --git a/docs/unix.html b/docs/unix.html new file mode 100644 index 0000000..de71925 --- /dev/null +++ b/docs/unix.html | |||
| @@ -0,0 +1,795 @@ | |||
| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | ||
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> | ||
| 3 | <html> | ||
| 4 | |||
| 5 | <head> | ||
| 6 | <meta name="description" content="LuaSocket: Unix domain socket support"> | ||
| 7 | <meta name="keywords" content="Lua, LuaSocket, Socket, Unix, Domain, IPC, Library, Support"> | ||
| 8 | <title>LuaSocket: Unix domain socket support</title> | ||
| 9 | <link rel="stylesheet" href="reference.css" type="text/css"> | ||
| 10 | </head> | ||
| 11 | |||
| 12 | <body> | ||
| 13 | |||
| 14 | <!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 15 | |||
| 16 | <div class="header"> | ||
| 17 | <hr> | ||
| 18 | <center> | ||
| 19 | <table summary="LuaSocket logo"> | ||
| 20 | <tr><td align="center"><a href="http://www.lua.org"> | ||
| 21 | <img width="128" height="128" border="0" alt="LuaSocket" src="luasocket.png"> | ||
| 22 | </a></td></tr> | ||
| 23 | <tr><td align="center" valign="top">Network support for the Lua language | ||
| 24 | </td></tr> | ||
| 25 | </table> | ||
| 26 | <p class="bar"> | ||
| 27 | <a href="index.html">home</a> · | ||
| 28 | <a href="index.html#download">download</a> · | ||
| 29 | <a href="installation.html">installation</a> · | ||
| 30 | <a href="introduction.html">introduction</a> · | ||
| 31 | <a href="reference.html">reference</a> | ||
| 32 | </p> | ||
| 33 | </center> | ||
| 34 | <hr> | ||
| 35 | </div> | ||
| 36 | |||
| 37 | <!-- unix ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 38 | |||
| 39 | <h2 id="unix">Unix domain sockets</h2> | ||
| 40 | |||
| 41 | <p> | ||
| 42 | Unix domain sockets provide inter-process communication between processes | ||
| 43 | on the same host, addressed by a path in the file system rather than by an | ||
| 44 | IP address and port. LuaSocket supports both the stream (connection | ||
| 45 | oriented, like TCP) and datagram (connectionless, like UDP) flavors. | ||
| 46 | </p> | ||
| 47 | |||
| 48 | <p class="note"> | ||
| 49 | Note: This module is only built on Unix-like platforms (Linux, macOS, | ||
| 50 | BSD, Haiku). It is not available on Windows. | ||
| 51 | </p> | ||
| 52 | |||
| 53 | <p> | ||
| 54 | Unlike the core <tt>socket</tt> namespace, Unix domain socket support is a | ||
| 55 | separate module that must be required explicitly: | ||
| 56 | </p> | ||
| 57 | |||
| 58 | <pre class="example"> | ||
| 59 | -- loads the socket.unix module | ||
| 60 | local unix = require("socket.unix") | ||
| 61 | </pre> | ||
| 62 | |||
| 63 | <p> | ||
| 64 | The module table returned by <tt>require("socket.unix")</tt> exposes two | ||
| 65 | constructors, <a href="#socket.unix.stream"><tt>unix.stream()</tt></a> and | ||
| 66 | <a href="#socket.unix.dgram"><tt>unix.dgram()</tt></a>. For backwards | ||
| 67 | compatibility, <tt>unix.tcp</tt> and <tt>unix.udp</tt> are aliases for | ||
| 68 | <tt>stream</tt> and <tt>dgram</tt> respectively, and the module table | ||
| 69 | itself can be called directly as a shortcut for <tt>unix.stream()</tt> | ||
| 70 | (i.e. <tt>unix()</tt> is the same as <tt>unix.stream()</tt>). | ||
| 71 | </p> | ||
| 72 | |||
| 73 | <p class="note"> | ||
| 74 | Note: Paths passed to <a href="#stream.bind"><tt>bind</tt></a>, | ||
| 75 | <a href="#stream.connect"><tt>connect</tt></a> and their datagram | ||
| 76 | equivalents are limited by the platform's <tt>sun_path</tt> buffer size | ||
| 77 | (commonly around 100–108 bytes). A path that does not fit returns | ||
| 78 | <b><tt>nil</tt></b> followed by the error message '<tt>path too | ||
| 79 | long</tt>'. | ||
| 80 | </p> | ||
| 81 | |||
| 82 | <!-- stream ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 83 | |||
| 84 | <h3 id="stream">Stream (<tt>socket.unix.stream</tt>)</h3> | ||
| 85 | |||
| 86 | <p> | ||
| 87 | Stream Unix domain sockets behave like TCP sockets (see | ||
| 88 | <a href="tcp.html">TCP</a>): a freshly created object is a <em>master</em> | ||
| 89 | object, which becomes a <em>client</em> object after a successful | ||
| 90 | <a href="#stream.connect"><tt>connect</tt></a>, or a <em>server</em> | ||
| 91 | object after a successful <a href="#stream.listen"><tt>listen</tt></a> | ||
| 92 | (itself normally preceded by <a href="#stream.bind"><tt>bind</tt></a>). | ||
| 93 | Server objects produce client objects via | ||
| 94 | <a href="#stream.accept"><tt>accept</tt></a>. Most methods below work the | ||
| 95 | same way as their TCP counterparts, just addressed by path instead of | ||
| 96 | IP/port. | ||
| 97 | </p> | ||
| 98 | |||
| 99 | <!-- stream.accept ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 100 | |||
| 101 | <p class="name" id="stream.accept"> | ||
| 102 | server:<b>accept()</b> | ||
| 103 | </p> | ||
| 104 | |||
| 105 | <p class="description"> | ||
| 106 | Waits for a remote connection on the server object and returns a client | ||
| 107 | object representing that connection. Works exactly like | ||
| 108 | <a href="tcp.html#accept"><tt>tcp:accept</tt></a>. | ||
| 109 | </p> | ||
| 110 | |||
| 111 | <p class="return"> | ||
| 112 | If a connection is successfully accepted, a client object is returned. If a | ||
| 113 | timeout condition is met, the method returns <b><tt>nil</tt></b> followed | ||
| 114 | by the error string '<tt>timeout</tt>'. Other errors are reported by | ||
| 115 | <b><tt>nil</tt></b> followed by a message describing the error. | ||
| 116 | </p> | ||
| 117 | |||
| 118 | <!-- stream.bind ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 119 | |||
| 120 | <p class="name" id="stream.bind"> | ||
| 121 | master:<b>bind(</b>path<b>)</b><br> | ||
| 122 | master:<b>setsockname(</b>path<b>)</b> | ||
| 123 | </p> | ||
| 124 | |||
| 125 | <p class="description"> | ||
| 126 | Binds a master object to a file system <tt>path</tt>. <tt>setsockname</tt> | ||
| 127 | is an alias for <tt>bind</tt>. | ||
| 128 | </p> | ||
| 129 | |||
| 130 | <p class="parameters"> | ||
| 131 | <tt>Path</tt> is a string with the file system path to bind to. The path | ||
| 132 | must not already exist as a socket file — remove any stale socket | ||
| 133 | file left over from a previous run before binding. | ||
| 134 | </p> | ||
| 135 | |||
| 136 | <p class="return"> | ||
| 137 | In case of success, the method returns 1. In case of error, the method | ||
| 138 | returns <b><tt>nil</tt></b> followed by an error message. | ||
| 139 | </p> | ||
| 140 | |||
| 141 | <!-- stream.close +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 142 | |||
| 143 | <p class="name" id="stream.close"> | ||
| 144 | master:<b>close()</b><br> | ||
| 145 | client:<b>close()</b><br> | ||
| 146 | server:<b>close()</b> | ||
| 147 | </p> | ||
| 148 | |||
| 149 | <p class="description"> | ||
| 150 | Closes a stream Unix domain object. The internal socket used by the object | ||
| 151 | is closed. No further operations (except further calls to | ||
| 152 | <tt>close</tt>) are allowed on a closed socket. | ||
| 153 | </p> | ||
| 154 | |||
| 155 | <p class="note"> | ||
| 156 | Note: Closing a socket does not remove the bound path from the file | ||
| 157 | system. Delete the socket file yourself (e.g. <tt>os.remove(path)</tt>) | ||
| 158 | once the server is done with it. | ||
| 159 | </p> | ||
| 160 | |||
| 161 | <p class="note"> | ||
| 162 | Note: Garbage-collected objects are automatically closed before | ||
| 163 | destruction. | ||
| 164 | </p> | ||
| 165 | |||
| 166 | <!-- stream.connect +++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 167 | |||
| 168 | <p class="name" id="stream.connect"> | ||
| 169 | master:<b>connect(</b>path<b>)</b><br> | ||
| 170 | master:<b>setpeername(</b>path<b>)</b> | ||
| 171 | </p> | ||
| 172 | |||
| 173 | <p class="description"> | ||
| 174 | Attempts to connect a master object to <tt>path</tt>, transforming it | ||
| 175 | into a client object. <tt>setpeername</tt> is an alias for | ||
| 176 | <tt>connect</tt>. Client objects support | ||
| 177 | <a href="#stream.send"><tt>send</tt></a>, | ||
| 178 | <a href="#stream.receive"><tt>receive</tt></a>, | ||
| 179 | <a href="#stream.getsockname"><tt>getsockname</tt></a>, | ||
| 180 | <a href="#stream.settimeout"><tt>settimeout</tt></a>, | ||
| 181 | <a href="#stream.shutdown"><tt>shutdown</tt></a>, and | ||
| 182 | <a href="#stream.close"><tt>close</tt></a>. | ||
| 183 | </p> | ||
| 184 | |||
| 185 | <p class="parameters"> | ||
| 186 | <tt>Path</tt> is a string with the file system path of a listening server | ||
| 187 | object. | ||
| 188 | </p> | ||
| 189 | |||
| 190 | <p class="return"> | ||
| 191 | In case of error, the method returns <b><tt>nil</tt></b> followed by a | ||
| 192 | string describing the error. In case of success, the method returns 1. | ||
| 193 | </p> | ||
| 194 | |||
| 195 | <!-- stream.dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 196 | |||
| 197 | <p class="name" id="stream.dirty"> | ||
| 198 | master:<b>dirty()</b><br> | ||
| 199 | client:<b>dirty()</b><br> | ||
| 200 | server:<b>dirty()</b> | ||
| 201 | </p> | ||
| 202 | |||
| 203 | <p class="description"> | ||
| 204 | Check the read buffer status. | ||
| 205 | </p> | ||
| 206 | |||
| 207 | <p class="return"> | ||
| 208 | Returns <tt>true</tt> if there is any data in the read buffer, | ||
| 209 | <tt>false</tt> otherwise. | ||
| 210 | </p> | ||
| 211 | |||
| 212 | <p class="note"> | ||
| 213 | Note: <b>This is an internal method, use at your own risk.</b> | ||
| 214 | </p> | ||
| 215 | |||
| 216 | <!-- stream.getfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 217 | |||
| 218 | <p class="name" id="stream.getfd"> | ||
| 219 | master:<b>getfd()</b><br> | ||
| 220 | client:<b>getfd()</b><br> | ||
| 221 | server:<b>getfd()</b> | ||
| 222 | </p> | ||
| 223 | |||
| 224 | <p class="description"> | ||
| 225 | Returns the underlying socket descriptor or handle associated to the | ||
| 226 | object. | ||
| 227 | </p> | ||
| 228 | |||
| 229 | <p class="return"> | ||
| 230 | The descriptor or handle. | ||
| 231 | </p> | ||
| 232 | |||
| 233 | <p class="note"> | ||
| 234 | Note: <b>This is an internal method. Unlikely to be portable. Use at your | ||
| 235 | own risk.</b> | ||
| 236 | </p> | ||
| 237 | |||
| 238 | <!-- stream.getsockname +++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 239 | |||
| 240 | <p class="name" id="stream.getsockname"> | ||
| 241 | master:<b>getsockname()</b><br> | ||
| 242 | client:<b>getsockname()</b><br> | ||
| 243 | server:<b>getsockname()</b> | ||
| 244 | </p> | ||
| 245 | |||
| 246 | <p class="description"> | ||
| 247 | Returns the local path the object is bound to. | ||
| 248 | </p> | ||
| 249 | |||
| 250 | <p class="return"> | ||
| 251 | The method returns a string with the local path. In case of error, the | ||
| 252 | method returns <b><tt>nil</tt></b>. | ||
| 253 | </p> | ||
| 254 | |||
| 255 | <!-- stream.getstats +++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 256 | |||
| 257 | <p class="name" id="stream.getstats"> | ||
| 258 | master:<b>getstats()</b><br> | ||
| 259 | client:<b>getstats()</b><br> | ||
| 260 | server:<b>getstats()</b> | ||
| 261 | </p> | ||
| 262 | |||
| 263 | <p class="description"> | ||
| 264 | Returns accounting information on the socket, useful for throttling of | ||
| 265 | bandwidth. Works exactly like <a href="tcp.html#getstats"><tt>tcp:getstats</tt></a>. | ||
| 266 | </p> | ||
| 267 | |||
| 268 | <p class="return"> | ||
| 269 | The method returns the number of bytes received, the number of bytes | ||
| 270 | sent, and the age of the socket object in seconds. | ||
| 271 | </p> | ||
| 272 | |||
| 273 | <!-- stream.listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 274 | |||
| 275 | <p class="name" id="stream.listen"> | ||
| 276 | master:<b>listen(</b>[backlog]<b>)</b> | ||
| 277 | </p> | ||
| 278 | |||
| 279 | <p class="description"> | ||
| 280 | Specifies the socket is willing to receive connections, transforming the | ||
| 281 | object into a server object. Server objects support | ||
| 282 | <a href="#stream.accept"><tt>accept</tt></a>, | ||
| 283 | <a href="#stream.getsockname"><tt>getsockname</tt></a>, | ||
| 284 | <a href="#stream.setoption"><tt>setoption</tt></a>, | ||
| 285 | <a href="#stream.settimeout"><tt>settimeout</tt></a>, and | ||
| 286 | <a href="#stream.close"><tt>close</tt></a>. | ||
| 287 | </p> | ||
| 288 | |||
| 289 | <p class="parameters"> | ||
| 290 | The optional <tt>backlog</tt> parameter specifies the number of client | ||
| 291 | connections that can be queued waiting for service. Defaults to 32. | ||
| 292 | </p> | ||
| 293 | |||
| 294 | <p class="return"> | ||
| 295 | In case of success, the method returns 1. In case of error, the method | ||
| 296 | returns <b><tt>nil</tt></b> followed by an error message. | ||
| 297 | </p> | ||
| 298 | |||
| 299 | <!-- stream.receive +++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 300 | |||
| 301 | <p class="name" id="stream.receive"> | ||
| 302 | client:<b>receive(</b>[pattern [, prefix [, maxsize]]]<b>)</b> | ||
| 303 | </p> | ||
| 304 | |||
| 305 | <p class="description"> | ||
| 306 | Reads data from a client object. Works exactly like | ||
| 307 | <a href="tcp.html#receive"><tt>tcp:receive</tt></a>, including the | ||
| 308 | <tt>*a</tt>/<tt>*l</tt>/<tt>number</tt> patterns and the | ||
| 309 | <tt>prefix</tt>/<tt>maxsize</tt> parameters. | ||
| 310 | </p> | ||
| 311 | |||
| 312 | <!-- stream.send +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 313 | |||
| 314 | <p class="name" id="stream.send"> | ||
| 315 | client:<b>send(</b>data [, i [, j]]<b>)</b> | ||
| 316 | </p> | ||
| 317 | |||
| 318 | <p class="description"> | ||
| 319 | Sends <tt>data</tt> through a client object. Works exactly like | ||
| 320 | <a href="tcp.html#send"><tt>tcp:send</tt></a>, including the optional | ||
| 321 | <tt>i</tt>/<tt>j</tt> substring selection. | ||
| 322 | </p> | ||
| 323 | |||
| 324 | <!-- stream.setfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 325 | |||
| 326 | <p class="name" id="stream.setfd"> | ||
| 327 | master:<b>setfd(</b>fd<b>)</b><br> | ||
| 328 | client:<b>setfd(</b>fd<b>)</b><br> | ||
| 329 | server:<b>setfd(</b>fd<b>)</b> | ||
| 330 | </p> | ||
| 331 | |||
| 332 | <p class="description"> | ||
| 333 | Sets the underlying socket descriptor or handle associated to the object. | ||
| 334 | The current one is simply replaced, not closed, and no other change to | ||
| 335 | the object state is made. | ||
| 336 | </p> | ||
| 337 | |||
| 338 | <p class="return"> | ||
| 339 | No return value. | ||
| 340 | </p> | ||
| 341 | |||
| 342 | <p class="note"> | ||
| 343 | Note: <b>This is an internal method. Unlikely to be portable. Use at your | ||
| 344 | own risk.</b> | ||
| 345 | </p> | ||
| 346 | |||
| 347 | <!-- stream.setoption +++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 348 | |||
| 349 | <p class="name" id="stream.setoption"> | ||
| 350 | client:<b>setoption(</b>option [, value]<b>)</b><br> | ||
| 351 | server:<b>setoption(</b>option [, value]<b>)</b> | ||
| 352 | </p> | ||
| 353 | |||
| 354 | <p class="description"> | ||
| 355 | Sets options for the stream object. Options are only needed by low-level | ||
| 356 | or time-critical applications. You should only modify an option if you | ||
| 357 | are sure you need it. | ||
| 358 | </p> | ||
| 359 | |||
| 360 | <p class="parameters"> | ||
| 361 | <tt>Option</tt> is a string with the option name, and <tt>value</tt> | ||
| 362 | depends on the option being set: | ||
| 363 | </p> | ||
| 364 | |||
| 365 | <ul> | ||
| 366 | <li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables | ||
| 367 | the periodic transmission of messages on a connected socket. See | ||
| 368 | <a href="tcp.html#setoption"><tt>tcp:setoption</tt></a> for details;</li> | ||
| 369 | <li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules | ||
| 370 | used in validating addresses supplied in a call to | ||
| 371 | <a href="#stream.bind"><tt>bind</tt></a> should allow reuse of local | ||
| 372 | addresses;</li> | ||
| 373 | <li> '<tt>linger</tt>': Controls the action taken when unsent data are | ||
| 374 | queued on a socket and a close is performed. See | ||
| 375 | <a href="tcp.html#setoption"><tt>tcp:setoption</tt></a> for the full | ||
| 376 | description of the <tt>on</tt>/<tt>timeout</tt> value table.</li> | ||
| 377 | </ul> | ||
| 378 | |||
| 379 | <p class="return"> | ||
| 380 | The method returns 1 in case of success, or <b><tt>nil</tt></b> followed | ||
| 381 | by an error message otherwise. | ||
| 382 | </p> | ||
| 383 | |||
| 384 | <!-- stream.setstats +++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 385 | |||
| 386 | <p class="name" id="stream.setstats"> | ||
| 387 | master:<b>setstats(</b>received, sent, age<b>)</b><br> | ||
| 388 | client:<b>setstats(</b>received, sent, age<b>)</b><br> | ||
| 389 | server:<b>setstats(</b>received, sent, age<b>)</b> | ||
| 390 | </p> | ||
| 391 | |||
| 392 | <p class="description"> | ||
| 393 | Resets accounting information on the socket, useful for throttling of | ||
| 394 | bandwidth. Works exactly like | ||
| 395 | <a href="tcp.html#setstats"><tt>tcp:setstats</tt></a>. | ||
| 396 | </p> | ||
| 397 | |||
| 398 | <p class="return"> | ||
| 399 | The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. | ||
| 400 | </p> | ||
| 401 | |||
| 402 | <!-- stream.settimeout +++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 403 | |||
| 404 | <p class="name" id="stream.settimeout"> | ||
| 405 | master:<b>settimeout(</b>value [, mode]<b>)</b><br> | ||
| 406 | client:<b>settimeout(</b>value [, mode]<b>)</b><br> | ||
| 407 | server:<b>settimeout(</b>value [, mode]<b>)</b> | ||
| 408 | </p> | ||
| 409 | |||
| 410 | <p class="description"> | ||
| 411 | Changes the timeout values for the object. Works exactly like | ||
| 412 | <a href="tcp.html#settimeout"><tt>tcp:settimeout</tt></a>, including the | ||
| 413 | '<tt>b</tt>' (block) and '<tt>t</tt>' (total) modes. | ||
| 414 | </p> | ||
| 415 | |||
| 416 | <!-- stream.shutdown ++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 417 | |||
| 418 | <p class="name" id="stream.shutdown"> | ||
| 419 | client:<b>shutdown(</b>[mode]<b>)</b> | ||
| 420 | </p> | ||
| 421 | |||
| 422 | <p class="description"> | ||
| 423 | Shuts down part of a full-duplex connection. Works exactly like | ||
| 424 | <a href="tcp.html#shutdown"><tt>tcp:shutdown</tt></a>. | ||
| 425 | </p> | ||
| 426 | |||
| 427 | <p class="parameters"> | ||
| 428 | <tt>Mode</tt> can be "<tt>both</tt>" (default), "<tt>send</tt>" or | ||
| 429 | "<tt>receive</tt>". | ||
| 430 | </p> | ||
| 431 | |||
| 432 | <p class="return"> | ||
| 433 | This function returns 1. | ||
| 434 | </p> | ||
| 435 | |||
| 436 | <!-- socket.unix.stream +++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 437 | |||
| 438 | <p class="name" id="socket.unix.stream"> | ||
| 439 | unix.<b>stream()</b> | ||
| 440 | </p> | ||
| 441 | |||
| 442 | <p class="description"> | ||
| 443 | Creates and returns a stream Unix domain master object. A master object | ||
| 444 | can be transformed into a server object with | ||
| 445 | <a href="#stream.listen"><tt>listen</tt></a> (after a call to | ||
| 446 | <a href="#stream.bind"><tt>bind</tt></a>) or into a client object with | ||
| 447 | <a href="#stream.connect"><tt>connect</tt></a>. The only other method | ||
| 448 | supported by a master object is <a href="#stream.close"><tt>close</tt></a>. | ||
| 449 | </p> | ||
| 450 | |||
| 451 | <p class="return"> | ||
| 452 | In case of success, a new master object is returned. In case of error, | ||
| 453 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
| 454 | </p> | ||
| 455 | |||
| 456 | <!-- dgram +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 457 | |||
| 458 | <h3 id="dgram">Datagram (<tt>socket.unix.dgram</tt>)</h3> | ||
| 459 | |||
| 460 | <p> | ||
| 461 | Datagram Unix domain sockets behave like UDP sockets (see | ||
| 462 | <a href="udp.html">UDP</a>): a socket starts out unconnected, and can | ||
| 463 | optionally be turned into a connected socket with | ||
| 464 | <a href="#dgram.connect"><tt>connect</tt></a> for repeated exchanges with | ||
| 465 | a single peer. | ||
| 466 | </p> | ||
| 467 | |||
| 468 | <!-- dgram.bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 469 | |||
| 470 | <p class="name" id="dgram.bind"> | ||
| 471 | unconnected:<b>bind(</b>path<b>)</b><br> | ||
| 472 | unconnected:<b>setsockname(</b>path<b>)</b> | ||
| 473 | </p> | ||
| 474 | |||
| 475 | <p class="description"> | ||
| 476 | Binds the datagram object to a local file system <tt>path</tt>. | ||
| 477 | <tt>setsockname</tt> is an alias for <tt>bind</tt>. Binding is only | ||
| 478 | required if you want other processes to be able to | ||
| 479 | <a href="#dgram.sendto"><tt>sendto</tt></a> this object; it is not | ||
| 480 | required to <a href="#dgram.sendto"><tt>sendto</tt></a> or | ||
| 481 | <a href="#dgram.connect"><tt>connect</tt></a> from it. | ||
| 482 | </p> | ||
| 483 | |||
| 484 | <p class="return"> | ||
| 485 | In case of success, the method returns 1. In case of error, the method | ||
| 486 | returns <b><tt>nil</tt></b> followed by an error message. | ||
| 487 | </p> | ||
| 488 | |||
| 489 | <!-- dgram.close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 490 | |||
| 491 | <p class="name" id="dgram.close"> | ||
| 492 | connected:<b>close()</b><br> | ||
| 493 | unconnected:<b>close()</b> | ||
| 494 | </p> | ||
| 495 | |||
| 496 | <p class="description"> | ||
| 497 | Closes a datagram Unix domain object. | ||
| 498 | </p> | ||
| 499 | |||
| 500 | <p class="note"> | ||
| 501 | Note: Closing a socket does not remove the bound path from the file | ||
| 502 | system. Delete the socket file yourself (e.g. <tt>os.remove(path)</tt>) | ||
| 503 | once you are done with it. | ||
| 504 | </p> | ||
| 505 | |||
| 506 | <p class="note"> | ||
| 507 | Note: Garbage-collected objects are automatically closed before | ||
| 508 | destruction. | ||
| 509 | </p> | ||
| 510 | |||
| 511 | <!-- dgram.connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 512 | |||
| 513 | <p class="name" id="dgram.connect"> | ||
| 514 | connected:<b>connect(</b>path<b>)</b><br> | ||
| 515 | unconnected:<b>connect(</b>path<b>)</b><br> | ||
| 516 | connected:<b>setpeername(</b>path<b>)</b><br> | ||
| 517 | unconnected:<b>setpeername(</b>path<b>)</b> | ||
| 518 | </p> | ||
| 519 | |||
| 520 | <p class="description"> | ||
| 521 | Sets (or changes) the peer of a datagram object, turning an unconnected | ||
| 522 | object into a connected one. <tt>setpeername</tt> is an alias for | ||
| 523 | <tt>connect</tt>. | ||
| 524 | </p> | ||
| 525 | |||
| 526 | <p class="parameters"> | ||
| 527 | <tt>Path</tt> is a string with the file system path of the peer. | ||
| 528 | </p> | ||
| 529 | |||
| 530 | <p class="return"> | ||
| 531 | In case of error, the method returns <b><tt>nil</tt></b> followed by an | ||
| 532 | error message. In case of success, the method returns 1. | ||
| 533 | </p> | ||
| 534 | |||
| 535 | <p class="note"> | ||
| 536 | Note: Unlike <a href="udp.html#setpeername"><tt>udp:setpeername</tt></a>, | ||
| 537 | there is no '<tt>*</tt>' path to dissolve the peer association back to an | ||
| 538 | unconnected socket. | ||
| 539 | </p> | ||
| 540 | |||
| 541 | <!-- dgram.dirty ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 542 | |||
| 543 | <p class="name" id="dgram.dirty"> | ||
| 544 | connected:<b>dirty()</b><br> | ||
| 545 | unconnected:<b>dirty()</b> | ||
| 546 | </p> | ||
| 547 | |||
| 548 | <p class="description"> | ||
| 549 | Check the read buffer status. | ||
| 550 | </p> | ||
| 551 | |||
| 552 | <p class="return"> | ||
| 553 | Always returns <tt>false</tt>. Datagram objects do not keep a read | ||
| 554 | buffer. | ||
| 555 | </p> | ||
| 556 | |||
| 557 | <p class="note"> | ||
| 558 | Note: <b>This is an internal method, use at your own risk.</b> | ||
| 559 | </p> | ||
| 560 | |||
| 561 | <!-- dgram.getfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 562 | |||
| 563 | <p class="name" id="dgram.getfd"> | ||
| 564 | connected:<b>getfd()</b><br> | ||
| 565 | unconnected:<b>getfd()</b> | ||
| 566 | </p> | ||
| 567 | |||
| 568 | <p class="description"> | ||
| 569 | Returns the underlying socket descriptor or handle associated to the | ||
| 570 | object. | ||
| 571 | </p> | ||
| 572 | |||
| 573 | <p class="return"> | ||
| 574 | The descriptor or handle. | ||
| 575 | </p> | ||
| 576 | |||
| 577 | <p class="note"> | ||
| 578 | Note: <b>This is an internal method. Unlikely to be portable. Use at your | ||
| 579 | own risk.</b> | ||
| 580 | </p> | ||
| 581 | |||
| 582 | <!-- dgram.getsockname +++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 583 | |||
| 584 | <p class="name" id="dgram.getsockname"> | ||
| 585 | connected:<b>getsockname()</b><br> | ||
| 586 | unconnected:<b>getsockname()</b> | ||
| 587 | </p> | ||
| 588 | |||
| 589 | <p class="description"> | ||
| 590 | Returns the local path the object is bound to. | ||
| 591 | </p> | ||
| 592 | |||
| 593 | <p class="return"> | ||
| 594 | The method returns a string with the local path. In case of error, the | ||
| 595 | method returns <b><tt>nil</tt></b>. | ||
| 596 | </p> | ||
| 597 | |||
| 598 | <!-- dgram.gettimeout +++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 599 | |||
| 600 | <p class="name" id="dgram.gettimeout"> | ||
| 601 | connected:<b>gettimeout()</b><br> | ||
| 602 | unconnected:<b>gettimeout()</b> | ||
| 603 | </p> | ||
| 604 | |||
| 605 | <p class="description"> | ||
| 606 | Returns the current timeout value. | ||
| 607 | </p> | ||
| 608 | |||
| 609 | <!-- dgram.receive +++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 610 | |||
| 611 | <p class="name" id="dgram.receive"> | ||
| 612 | connected:<b>receive(</b>[size]<b>)</b><br> | ||
| 613 | unconnected:<b>receive(</b>[size]<b>)</b> | ||
| 614 | </p> | ||
| 615 | |||
| 616 | <p class="description"> | ||
| 617 | Receives a datagram from the object. If the object is connected, only | ||
| 618 | datagrams coming from the peer are accepted. | ||
| 619 | </p> | ||
| 620 | |||
| 621 | <p class="parameters"> | ||
| 622 | The optional <tt>size</tt> parameter specifies the maximum size of the | ||
| 623 | datagram to be retrieved (defaults to 8192 bytes). | ||
| 624 | </p> | ||
| 625 | |||
| 626 | <p class="return"> | ||
| 627 | In case of success, the method returns the received datagram, which may | ||
| 628 | be the empty string (a valid zero-length datagram, not end-of-stream). In | ||
| 629 | case of timeout, the method returns <b><tt>nil</tt></b> followed by the | ||
| 630 | string '<tt>timeout</tt>'. | ||
| 631 | </p> | ||
| 632 | |||
| 633 | <!-- dgram.receivefrom +++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 634 | |||
| 635 | <p class="name" id="dgram.receivefrom"> | ||
| 636 | unconnected:<b>receivefrom(</b>[size]<b>)</b> | ||
| 637 | </p> | ||
| 638 | |||
| 639 | <p class="description"> | ||
| 640 | Works exactly as <a href="#dgram.receive"><tt>receive</tt></a>, except it | ||
| 641 | also returns the sender's path as a second return value. | ||
| 642 | </p> | ||
| 643 | |||
| 644 | <p class="return"> | ||
| 645 | In case of success, the method returns the received datagram followed by | ||
| 646 | the sender's path (the empty string if the sender's socket was not | ||
| 647 | bound). In case of timeout, the method returns <b><tt>nil</tt></b> | ||
| 648 | followed by the string '<tt>timeout</tt>'. | ||
| 649 | </p> | ||
| 650 | |||
| 651 | <!-- dgram.send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 652 | |||
| 653 | <p class="name" id="dgram.send"> | ||
| 654 | connected:<b>send(</b>datagram<b>)</b> | ||
| 655 | </p> | ||
| 656 | |||
| 657 | <p class="description"> | ||
| 658 | Sends a datagram to the peer of a connected object. | ||
| 659 | </p> | ||
| 660 | |||
| 661 | <p class="return"> | ||
| 662 | If successful, the method returns the number of bytes sent. In case of | ||
| 663 | error, the method returns <b><tt>nil</tt></b> followed by an error | ||
| 664 | message (the string '<tt>refused</tt>' if the peer's socket is not | ||
| 665 | accepting datagrams). | ||
| 666 | </p> | ||
| 667 | |||
| 668 | <!-- dgram.sendto +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 669 | |||
| 670 | <p class="name" id="dgram.sendto"> | ||
| 671 | unconnected:<b>sendto(</b>datagram, path<b>)</b> | ||
| 672 | </p> | ||
| 673 | |||
| 674 | <p class="description"> | ||
| 675 | Sends a datagram to the object bound to <tt>path</tt>. | ||
| 676 | </p> | ||
| 677 | |||
| 678 | <p class="parameters"> | ||
| 679 | <tt>Datagram</tt> is a string with the datagram contents. <tt>Path</tt> | ||
| 680 | is the file system path of the recipient. | ||
| 681 | </p> | ||
| 682 | |||
| 683 | <p class="return"> | ||
| 684 | If successful, the method returns the number of bytes sent. In case of | ||
| 685 | error, the method returns <b><tt>nil</tt></b> followed by an error | ||
| 686 | message (the string '<tt>refused</tt>' if the recipient's socket is not | ||
| 687 | accepting datagrams). | ||
| 688 | </p> | ||
| 689 | |||
| 690 | <!-- dgram.setfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 691 | |||
| 692 | <p class="name" id="dgram.setfd"> | ||
| 693 | connected:<b>setfd(</b>fd<b>)</b><br> | ||
| 694 | unconnected:<b>setfd(</b>fd<b>)</b> | ||
| 695 | </p> | ||
| 696 | |||
| 697 | <p class="description"> | ||
| 698 | Sets the underlying socket descriptor or handle associated to the object. | ||
| 699 | </p> | ||
| 700 | |||
| 701 | <p class="return"> | ||
| 702 | No return value. | ||
| 703 | </p> | ||
| 704 | |||
| 705 | <p class="note"> | ||
| 706 | Note: <b>This is an internal method. Unlikely to be portable. Use at your | ||
| 707 | own risk.</b> | ||
| 708 | </p> | ||
| 709 | |||
| 710 | <!-- dgram.setoption +++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 711 | |||
| 712 | <p class="name" id="dgram.setoption"> | ||
| 713 | connected:<b>setoption(</b>option [, value]<b>)</b><br> | ||
| 714 | unconnected:<b>setoption(</b>option [, value]<b>)</b> | ||
| 715 | </p> | ||
| 716 | |||
| 717 | <p class="description"> | ||
| 718 | Sets options for the datagram object. | ||
| 719 | </p> | ||
| 720 | |||
| 721 | <p class="parameters"> | ||
| 722 | <tt>Option</tt> is a string with the option name: | ||
| 723 | </p> | ||
| 724 | |||
| 725 | <ul> | ||
| 726 | <li> '<tt>reuseaddr</tt>': Indicates that the rules used in validating | ||
| 727 | addresses supplied in a <a href="#dgram.bind"><tt>bind</tt></a> call | ||
| 728 | should allow reuse of local addresses. Receives a boolean value.</li> | ||
| 729 | </ul> | ||
| 730 | |||
| 731 | <p class="return"> | ||
| 732 | The method returns 1 in case of success, or <b><tt>nil</tt></b> followed | ||
| 733 | by an error message otherwise. | ||
| 734 | </p> | ||
| 735 | |||
| 736 | <!-- dgram.settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 737 | |||
| 738 | <p class="name" id="dgram.settimeout"> | ||
| 739 | connected:<b>settimeout(</b>value<b>)</b><br> | ||
| 740 | unconnected:<b>settimeout(</b>value<b>)</b> | ||
| 741 | </p> | ||
| 742 | |||
| 743 | <p class="description"> | ||
| 744 | Changes the timeout value for the object. Works like | ||
| 745 | <a href="udp.html#settimeout"><tt>udp:settimeout</tt></a>: since | ||
| 746 | <a href="#dgram.send"><tt>send</tt></a> and | ||
| 747 | <a href="#dgram.sendto"><tt>sendto</tt></a> never block, this only | ||
| 748 | affects <a href="#dgram.receive"><tt>receive</tt></a> and | ||
| 749 | <a href="#dgram.receivefrom"><tt>receivefrom</tt></a>. | ||
| 750 | </p> | ||
| 751 | |||
| 752 | <!-- socket.unix.dgram +++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 753 | |||
| 754 | <p class="name" id="socket.unix.dgram"> | ||
| 755 | unix.<b>dgram()</b> | ||
| 756 | </p> | ||
| 757 | |||
| 758 | <p class="description"> | ||
| 759 | Creates and returns an unconnected datagram Unix domain object. | ||
| 760 | Unconnected objects support | ||
| 761 | <a href="#dgram.sendto"><tt>sendto</tt></a>, | ||
| 762 | <a href="#dgram.receive"><tt>receive</tt></a>, | ||
| 763 | <a href="#dgram.receivefrom"><tt>receivefrom</tt></a>, | ||
| 764 | <a href="#dgram.getsockname"><tt>getsockname</tt></a>, | ||
| 765 | <a href="#dgram.setoption"><tt>setoption</tt></a>, | ||
| 766 | <a href="#dgram.settimeout"><tt>settimeout</tt></a>, | ||
| 767 | <a href="#dgram.connect"><tt>connect</tt></a>, and | ||
| 768 | <a href="#dgram.close"><tt>close</tt></a>. Use | ||
| 769 | <a href="#dgram.connect"><tt>connect</tt></a> to turn the object into a | ||
| 770 | connected object. | ||
| 771 | </p> | ||
| 772 | |||
| 773 | <p class="return"> | ||
| 774 | In case of success, a new unconnected datagram object is returned. In | ||
| 775 | case of error, <b><tt>nil</tt></b> is returned, followed by an error | ||
| 776 | message. | ||
| 777 | </p> | ||
| 778 | |||
| 779 | <!-- footer ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 780 | |||
| 781 | <div class="footer"> | ||
| 782 | <hr> | ||
| 783 | <center> | ||
| 784 | <p class="bar"> | ||
| 785 | <a href="index.html">home</a> · | ||
| 786 | <a href="index.html#download">download</a> · | ||
| 787 | <a href="installation.html">installation</a> · | ||
| 788 | <a href="introduction.html">introduction</a> · | ||
| 789 | <a href="reference.html">reference</a> | ||
| 790 | </p> | ||
| 791 | </center> | ||
| 792 | </div> | ||
| 793 | |||
| 794 | </body> | ||
| 795 | </html> | ||
