aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/dns.html26
-rw-r--r--docs/http.html9
-rw-r--r--docs/index.html2
-rw-r--r--docs/installation.html2
-rw-r--r--docs/introduction.html5
-rw-r--r--docs/ltn12.html38
-rw-r--r--docs/reference.html72
-rw-r--r--docs/serial.html308
-rw-r--r--docs/socket.html29
-rw-r--r--docs/tcp.html43
-rw-r--r--docs/udp.html88
-rw-r--r--docs/unix.html795
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>
106followed by an error message. 106followed by an error message.
107</p> 107</p>
108 108
109<!-- getnameinfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
110
111<p class="name" id="getnameinfo">
112socket.dns.<b>getnameinfo(</b>[host] [, service]<b>)</b>
113</p>
114
115<p class="description">
116Resolves a host and/or a service name through the system resolver and
117returns 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">
127If <tt>host</tt> was given, returns a numerically-indexed table with the
128canonical host name found for each address the resolver returns for
129<tt>host</tt>. If <tt>service</tt> was also given, the canonical service
130name is returned as an additional value; if only <tt>service</tt> was
131given, its canonical name is returned by itself. In case of error, the
132function 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
119header line. Defaults to 8192;</li>
120<li> <tt>MAXHEADERSIZE</tt>: maximum total size, in bytes, of all response
121header 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.
183Defaults to the LTN12 <tt>pump.step</tt> function.</li> 187Defaults 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
186function from automatically following 301 or 302 server redirect messages;</li> 190function from automatically following 301, 302, 303, 307 or 308 server
191redirect 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.
70On Unix-like platforms, dedicated <a href="unix.html">Unix domain socket</a>
71and <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
305much more than TCP and UDP functionality. As the library 305much more than TCP and UDP functionality. As the library
306evolved, support for <a href=http.html>HTTP</a>, <a href=ftp.html>FTP</a>, 306evolved, support for <a href=http.html>HTTP</a>, <a href=ftp.html>FTP</a>,
307and <a href=smtp.html>SMTP</a> were built on top of these. These modules 307and <a href=smtp.html>SMTP</a> were built on top of these. On Unix-like
308platforms, the library also ships separate <a href=unix.html>Unix domain
309socket</a> and <a href=serial.html>serial port</a> modules, requirable as
310<tt>socket.unix</tt> and <tt>socket.serial</tt>. These modules
308and many others are covered by the <a href=reference.html>reference manual</a>. 311and 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:
55local ltn12 = require("ltn12") 55local ltn12 = require("ltn12")
56</pre> 56</pre>
57 57
58<!-- BLOCKSIZE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
59
60<p class="name" id="BLOCKSIZE">
61ltn12.<b>BLOCKSIZE</b>
62</p>
63
64<p class="description">
65The default chunk size, in bytes, used internally by the built-in sources
66and 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
68natural chunk size of their own. Defaults to 2048. Changing it affects
69only 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>
415Creates 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. 429Creates 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">
435ltn12.source.<b>rewind(</b>source<b>)</b>
436</p>
437
438<p class="description">
439Wraps a <em>fancy</em> <tt>source</tt> to add chunk pushback, so previously
440produced 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">
448The function returns a new fancy source. Calling it with no arguments reads
449the next chunk as usual: any chunks previously pushed back are returned
450first (most recently pushed back, first), and once none remain it falls
451through to <tt>source</tt>. Calling it <em>with</em> a chunk argument does
452not read anything: it pushes that chunk back onto the internal stack for a
453future 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> &middot;
28<a href="index.html#download">download</a> &middot;
29<a href="installation.html">installation</a> &middot;
30<a href="introduction.html">introduction</a> &middot;
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>
42The <tt>socket.serial</tt> module opens a serial device (e.g.
43<tt>/dev/ttyUSB0</tt>) and exposes it through the same buffered,
44timeout-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>
46stream objects.
47</p>
48
49<p class="note">
50Note: This module is only built on Unix-like platforms (Linux, macOS,
51BSD, Haiku). It is not available on Windows.
52</p>
53
54<p>
55Serial port support is a separate module that must be required
56explicitly. Unlike most other LuaSocket modules, it returns a
57<em>function</em> directly &mdash; the constructor &mdash; rather than a
58table of functions:
59</p>
60
61<pre class="example">
62-- loads the socket.serial module; note this is the constructor itself
63local serial_open = require("socket.serial")
64
65-- open the device
66local port = assert(serial_open("/dev/ttyUSB0"))
67port:settimeout(1)
68assert(port:send("AT\r\n"))
69print(port:receive())
70port:close()
71</pre>
72
73<p class="note">
74Note: <b>There is currently no API to configure the serial line itself
75&mdash; baud rate, parity, data/stop bits or flow control.</b> The device
76is opened non-blocking with whatever settings the OS driver or a prior
77external configuration (e.g. <tt>stty</tt>) left it in. This is a known
78current limitation of the module, not a deliberate protection against
79misuse; a future version may add a <tt>setoption</tt>-style API for these
80settings the way <a href="tcp.html#setoption"><tt>tcp:setoption</tt></a>
81does for TCP.
82</p>
83
84<p>
85Until such an API exists, the workaround is to configure the line with
86the 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">
91local serial_open = require("socket.serial")
92
93local dev = "/dev/ttyUSB0"
94
95-- Linux: stty -F &lt;device&gt; ...
96local 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
102assert(ok, "failed to configure serial line with stty")
103
104local port = assert(serial_open(dev))
105port:settimeout(1)
106assert(port:send("AT\r\n"))
107print(port:receive())
108port:close()
109</pre>
110
111<p class="note">
112Note: <tt>raw -echo</tt> puts the line in raw mode, which matters for
113LuaSocket's framing: without it, the TTY driver applies its own line
114editing/echo, which can interfere with <a href="#receive"><tt>receive</tt></a>
115patterns 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
117your device; consult <tt>man stty</tt> for the full option set on your
118platform, since flag names and defaults vary between Linux, macOS and the
119BSDs.
120</p>
121
122<!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
123
124<p class="name" id="close">
125port:<b>close()</b>
126</p>
127
128<p class="description">
129Closes 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">
134Note: Garbage-collected objects are automatically closed before
135destruction.
136</p>
137
138<!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
139
140<p class="name" id="dirty">
141port:<b>dirty()</b>
142</p>
143
144<p class="description">
145Check the read buffer status.
146</p>
147
148<p class="return">
149Returns <tt>true</tt> if there is any data in the read buffer,
150<tt>false</tt> otherwise.
151</p>
152
153<p class="note">
154Note: <b>This is an internal method, use at your own risk.</b>
155</p>
156
157<!-- getfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
158
159<p class="name" id="getfd">
160port:<b>getfd()</b>
161</p>
162
163<p class="description">
164Returns the underlying file descriptor associated to the object.
165</p>
166
167<p class="return">
168The descriptor.
169</p>
170
171<p class="note">
172Note: <b>This is an internal method. Unlikely to be portable. Use at your
173own risk.</b>
174</p>
175
176<!-- getstats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
177
178<p class="name" id="getstats">
179port:<b>getstats()</b>
180</p>
181
182<p class="description">
183Returns accounting information on the port, useful for throttling of
184bandwidth. Works exactly like
185<a href="tcp.html#getstats"><tt>tcp:getstats</tt></a>.
186</p>
187
188<p class="return">
189The method returns the number of bytes received, the number of bytes
190sent, and the age of the object in seconds.
191</p>
192
193<!-- receive +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
194
195<p class="name" id="receive">
196port:<b>receive(</b>[pattern [, prefix [, maxsize]]]<b>)</b>
197</p>
198
199<p class="description">
200Reads data from the serial port, according to the specified <em>read
201pattern</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">
210port:<b>send(</b>data [, i [, j]]<b>)</b>
211</p>
212
213<p class="description">
214Sends <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">
222port:<b>setfd(</b>fd<b>)</b>
223</p>
224
225<p class="description">
226Sets the underlying file descriptor associated to the object. The current
227one is simply replaced, not closed, and no other change to the object
228state is made.
229</p>
230
231<p class="return">
232No return value.
233</p>
234
235<p class="note">
236Note: <b>This is an internal method. Unlikely to be portable. Use at your
237own risk.</b>
238</p>
239
240<!-- setstats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
241
242<p class="name" id="setstats">
243port:<b>setstats(</b>received, sent, age<b>)</b>
244</p>
245
246<p class="description">
247Resets accounting information on the port, useful for throttling of
248bandwidth. Works exactly like
249<a href="tcp.html#setstats"><tt>tcp:setstats</tt></a>.
250</p>
251
252<p class="return">
253The 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">
259port:<b>settimeout(</b>value [, mode]<b>)</b>
260</p>
261
262<p class="description">
263Changes 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">
271serial_open(<b>path</b>)
272</p>
273
274<p class="description">
275Opens the serial device at <tt>path</tt> and returns a serial object.
276This is the value returned directly by <tt>require("socket.serial")</tt>
277&mdash; 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">
287In case of success, a new serial object is returned. In case of error,
288the function returns <b><tt>nil</tt></b>, followed by an error message,
289followed 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> &middot;
299<a href="index.html#download">download</a> &middot;
300<a href="installation.html">installation</a> &middot;
301<a href="introduction.html">introduction</a> &middot;
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:
51local socket = require("socket") 51local socket = require("socket")
52</pre> 52</pre>
53 53
54<p>
55Two related transports are shipped as separate modules, loaded on demand
56with their own <tt>require</tt> call: <a href="unix.html">Unix domain
57sockets</a> (<tt>require("socket.unix")</tt>) and
58<a href="serial.html">serial ports</a> (<tt>require("socket.serial")</tt>).
59Both 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")
94headers.setcanonic("X-Request-ID") 102headers.setcanonic("X-Request-ID")
95</pre> 103</pre>
96 104
105<!-- headers.setcanonic +++++++++++++++++++++++++++++++++++++++++++++++++ -->
106
107<p class="name" id="headers.setcanonic">
108socket.headers.<b>setcanonic(</b>name<b>)</b>
109</p>
110
111<p class="description">
112Registers a custom canonic capitalization for a header field name in
113<a href="#headers.canonic"><tt>socket.headers.canonic</tt></a>, for use
114when the automatic capitalize-first-letter-of-each-word rule would not
115reproduce 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
120canonic capitalization (e.g. <tt>"X-Request-ID"</tt>).
121</p>
122
123<p class="return">
124No 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">
202master:<b>getfamily()</b><br>
203client:<b>getfamily()</b><br>
204server:<b>getfamily()</b>
205</p>
206
207<p class="description">
208Returns the family of the underlying socket, as chosen when the object was
209created 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">
215The 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>
651This function returns 1. 670This function returns 1.
652</p> 671</p>
653 672
673<!-- setpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
674
675<p class="name" id="setpeername">
676master:<b>setpeername(</b>address, port<b>)</b>
677</p>
678
679<p class="description">
680Alias for <a href="#connect"><tt>connect</tt></a>, kept for naming symmetry
681with <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">
688master:<b>setsockname(</b>address, port<b>)</b>
689</p>
690
691<p class="description">
692Alias for <a href="#bind"><tt>bind</tt></a>, kept for naming symmetry
693with <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
62destruction, though. 62destruction, though.
63</p> 63</p>
64 64
65<!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
66
67<p class="name" id="dirty">
68connected:<b>dirty()</b><br>
69unconnected:<b>dirty()</b>
70</p>
71
72<p class="description">
73Check the read buffer status.
74</p>
75
76<p class="return">
77Returns <tt>false</tt>. UDP objects do not keep a read buffer, so this
78always reports no buffered data.
79</p>
80
81<p class="note">
82Note: <b>This is an internal method, use at your own risk.</b>
83</p>
84
85<!-- getfamily +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
86
87<p class="name" id="getfamily">
88connected:<b>getfamily()</b><br>
89unconnected:<b>getfamily()</b>
90</p>
91
92<p class="description">
93Returns the family of the underlying socket, as chosen when the object was
94created 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">
100The string "<tt>inet4</tt>" or "<tt>inet6</tt>".
101</p>
102
103<!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
104
105<p class="name" id="getfd">
106connected:<b>getfd()</b><br>
107unconnected:<b>getfd()</b>
108</p>
109
110<p class="description">
111Returns the underling socket descriptor or handle associated to the object.
112</p>
113
114<p class="return">
115The descriptor or handle. In case the object has been closed, the return value
116will 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">
121Note: <b>This is an internal method. Unlikely to be
122portable. 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)
321for outgoing packets. 381for outgoing packets.
322Receives a number;</li> 382Receives a number;</li>
323<li> '<tt>ipv6-multicast-hops</tt>': 383<li> '<tt>ipv6-multicast-hops</tt>':
324Sets the hop limit for outgoing IPv6 multicast datagrams. 384<b>Known limitation:</b> this option is currently wired to the same
325Receives a number;</li> 385underlying setting as <tt>ipv6-unicast-hops</tt> instead of a separate
386multicast hop limit, so getting or setting one also gets or sets the
387other. Receives a number;</li>
326<li> '<tt>ipv6-multicast-loop</tt>': 388<li> '<tt>ipv6-multicast-loop</tt>':
327Specifies whether or not a copy of an outgoing IPv6 multicast 389Specifies whether or not a copy of an outgoing IPv6 multicast
328datagram is delivered to the sending host as long as it is a 390datagram 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">
442connected:<b>setfd(</b>fd<b>)</b><br>
443unconnected:<b>setfd(</b>fd<b>)</b>
444</p>
445
446<p class="description">
447Sets the underling socket descriptor or handle associated to the object. The current one
448is simply replaced, not closed, and no other change to the object state is made.
449To set it as invalid use <a href="socket.html#socketinvalid"><tt>_SOCKETINVALID</tt></a>.
450</p>
451
452<p class="return">
453No return value.
454</p>
455
456<p class="note">
457Note: <b>This is an internal method. Unlikely to be
458portable. 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> &middot;
28<a href="index.html#download">download</a> &middot;
29<a href="installation.html">installation</a> &middot;
30<a href="introduction.html">introduction</a> &middot;
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>
42Unix domain sockets provide inter-process communication between processes
43on the same host, addressed by a path in the file system rather than by an
44IP address and port. LuaSocket supports both the stream (connection
45oriented, like TCP) and datagram (connectionless, like UDP) flavors.
46</p>
47
48<p class="note">
49Note: This module is only built on Unix-like platforms (Linux, macOS,
50BSD, Haiku). It is not available on Windows.
51</p>
52
53<p>
54Unlike the core <tt>socket</tt> namespace, Unix domain socket support is a
55separate module that must be required explicitly:
56</p>
57
58<pre class="example">
59-- loads the socket.unix module
60local unix = require("socket.unix")
61</pre>
62
63<p>
64The module table returned by <tt>require("socket.unix")</tt> exposes two
65constructors, <a href="#socket.unix.stream"><tt>unix.stream()</tt></a> and
66<a href="#socket.unix.dgram"><tt>unix.dgram()</tt></a>. For backwards
67compatibility, <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
69itself 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">
74Note: Paths passed to <a href="#stream.bind"><tt>bind</tt></a>,
75<a href="#stream.connect"><tt>connect</tt></a> and their datagram
76equivalents are limited by the platform's <tt>sun_path</tt> buffer size
77(commonly around 100&ndash;108 bytes). A path that does not fit returns
78<b><tt>nil</tt></b> followed by the error message '<tt>path too
79long</tt>'.
80</p>
81
82<!-- stream ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
83
84<h3 id="stream">Stream (<tt>socket.unix.stream</tt>)</h3>
85
86<p>
87Stream Unix domain sockets behave like TCP sockets (see
88<a href="tcp.html">TCP</a>): a freshly created object is a <em>master</em>
89object, which becomes a <em>client</em> object after a successful
90<a href="#stream.connect"><tt>connect</tt></a>, or a <em>server</em>
91object after a successful <a href="#stream.listen"><tt>listen</tt></a>
92(itself normally preceded by <a href="#stream.bind"><tt>bind</tt></a>).
93Server objects produce client objects via
94<a href="#stream.accept"><tt>accept</tt></a>. Most methods below work the
95same way as their TCP counterparts, just addressed by path instead of
96IP/port.
97</p>
98
99<!-- stream.accept ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
100
101<p class="name" id="stream.accept">
102server:<b>accept()</b>
103</p>
104
105<p class="description">
106Waits for a remote connection on the server object and returns a client
107object representing that connection. Works exactly like
108<a href="tcp.html#accept"><tt>tcp:accept</tt></a>.
109</p>
110
111<p class="return">
112If a connection is successfully accepted, a client object is returned. If a
113timeout condition is met, the method returns <b><tt>nil</tt></b> followed
114by 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">
121master:<b>bind(</b>path<b>)</b><br>
122master:<b>setsockname(</b>path<b>)</b>
123</p>
124
125<p class="description">
126Binds a master object to a file system <tt>path</tt>. <tt>setsockname</tt>
127is 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
132must not already exist as a socket file &mdash; remove any stale socket
133file left over from a previous run before binding.
134</p>
135
136<p class="return">
137In case of success, the method returns 1. In case of error, the method
138returns <b><tt>nil</tt></b> followed by an error message.
139</p>
140
141<!-- stream.close +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
142
143<p class="name" id="stream.close">
144master:<b>close()</b><br>
145client:<b>close()</b><br>
146server:<b>close()</b>
147</p>
148
149<p class="description">
150Closes a stream Unix domain object. The internal socket used by the object
151is 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">
156Note: Closing a socket does not remove the bound path from the file
157system. Delete the socket file yourself (e.g. <tt>os.remove(path)</tt>)
158once the server is done with it.
159</p>
160
161<p class="note">
162Note: Garbage-collected objects are automatically closed before
163destruction.
164</p>
165
166<!-- stream.connect +++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
167
168<p class="name" id="stream.connect">
169master:<b>connect(</b>path<b>)</b><br>
170master:<b>setpeername(</b>path<b>)</b>
171</p>
172
173<p class="description">
174Attempts to connect a master object to <tt>path</tt>, transforming it
175into 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
187object.
188</p>
189
190<p class="return">
191In case of error, the method returns <b><tt>nil</tt></b> followed by a
192string 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">
198master:<b>dirty()</b><br>
199client:<b>dirty()</b><br>
200server:<b>dirty()</b>
201</p>
202
203<p class="description">
204Check the read buffer status.
205</p>
206
207<p class="return">
208Returns <tt>true</tt> if there is any data in the read buffer,
209<tt>false</tt> otherwise.
210</p>
211
212<p class="note">
213Note: <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">
219master:<b>getfd()</b><br>
220client:<b>getfd()</b><br>
221server:<b>getfd()</b>
222</p>
223
224<p class="description">
225Returns the underlying socket descriptor or handle associated to the
226object.
227</p>
228
229<p class="return">
230The descriptor or handle.
231</p>
232
233<p class="note">
234Note: <b>This is an internal method. Unlikely to be portable. Use at your
235own risk.</b>
236</p>
237
238<!-- stream.getsockname +++++++++++++++++++++++++++++++++++++++++++++++++ -->
239
240<p class="name" id="stream.getsockname">
241master:<b>getsockname()</b><br>
242client:<b>getsockname()</b><br>
243server:<b>getsockname()</b>
244</p>
245
246<p class="description">
247Returns the local path the object is bound to.
248</p>
249
250<p class="return">
251The method returns a string with the local path. In case of error, the
252method returns <b><tt>nil</tt></b>.
253</p>
254
255<!-- stream.getstats +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
256
257<p class="name" id="stream.getstats">
258master:<b>getstats()</b><br>
259client:<b>getstats()</b><br>
260server:<b>getstats()</b>
261</p>
262
263<p class="description">
264Returns accounting information on the socket, useful for throttling of
265bandwidth. Works exactly like <a href="tcp.html#getstats"><tt>tcp:getstats</tt></a>.
266</p>
267
268<p class="return">
269The method returns the number of bytes received, the number of bytes
270sent, and the age of the socket object in seconds.
271</p>
272
273<!-- stream.listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
274
275<p class="name" id="stream.listen">
276master:<b>listen(</b>[backlog]<b>)</b>
277</p>
278
279<p class="description">
280Specifies the socket is willing to receive connections, transforming the
281object 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">
290The optional <tt>backlog</tt> parameter specifies the number of client
291connections that can be queued waiting for service. Defaults to 32.
292</p>
293
294<p class="return">
295In case of success, the method returns 1. In case of error, the method
296returns <b><tt>nil</tt></b> followed by an error message.
297</p>
298
299<!-- stream.receive +++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
300
301<p class="name" id="stream.receive">
302client:<b>receive(</b>[pattern [, prefix [, maxsize]]]<b>)</b>
303</p>
304
305<p class="description">
306Reads 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">
315client:<b>send(</b>data [, i [, j]]<b>)</b>
316</p>
317
318<p class="description">
319Sends <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">
327master:<b>setfd(</b>fd<b>)</b><br>
328client:<b>setfd(</b>fd<b>)</b><br>
329server:<b>setfd(</b>fd<b>)</b>
330</p>
331
332<p class="description">
333Sets the underlying socket descriptor or handle associated to the object.
334The current one is simply replaced, not closed, and no other change to
335the object state is made.
336</p>
337
338<p class="return">
339No return value.
340</p>
341
342<p class="note">
343Note: <b>This is an internal method. Unlikely to be portable. Use at your
344own risk.</b>
345</p>
346
347<!-- stream.setoption +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
348
349<p class="name" id="stream.setoption">
350client:<b>setoption(</b>option [, value]<b>)</b><br>
351server:<b>setoption(</b>option [, value]<b>)</b>
352</p>
353
354<p class="description">
355Sets options for the stream object. Options are only needed by low-level
356or time-critical applications. You should only modify an option if you
357are 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>
362depends on the option being set:
363</p>
364
365<ul>
366<li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables
367the 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
370used in validating addresses supplied in a call to
371<a href="#stream.bind"><tt>bind</tt></a> should allow reuse of local
372addresses;</li>
373<li> '<tt>linger</tt>': Controls the action taken when unsent data are
374queued on a socket and a close is performed. See
375<a href="tcp.html#setoption"><tt>tcp:setoption</tt></a> for the full
376description of the <tt>on</tt>/<tt>timeout</tt> value table.</li>
377</ul>
378
379<p class="return">
380The method returns 1 in case of success, or <b><tt>nil</tt></b> followed
381by an error message otherwise.
382</p>
383
384<!-- stream.setstats +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
385
386<p class="name" id="stream.setstats">
387master:<b>setstats(</b>received, sent, age<b>)</b><br>
388client:<b>setstats(</b>received, sent, age<b>)</b><br>
389server:<b>setstats(</b>received, sent, age<b>)</b>
390</p>
391
392<p class="description">
393Resets accounting information on the socket, useful for throttling of
394bandwidth. Works exactly like
395<a href="tcp.html#setstats"><tt>tcp:setstats</tt></a>.
396</p>
397
398<p class="return">
399The 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">
405master:<b>settimeout(</b>value [, mode]<b>)</b><br>
406client:<b>settimeout(</b>value [, mode]<b>)</b><br>
407server:<b>settimeout(</b>value [, mode]<b>)</b>
408</p>
409
410<p class="description">
411Changes 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">
419client:<b>shutdown(</b>[mode]<b>)</b>
420</p>
421
422<p class="description">
423Shuts 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">
433This function returns 1.
434</p>
435
436<!-- socket.unix.stream +++++++++++++++++++++++++++++++++++++++++++++++++ -->
437
438<p class="name" id="socket.unix.stream">
439unix.<b>stream()</b>
440</p>
441
442<p class="description">
443Creates and returns a stream Unix domain master object. A master object
444can 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
448supported by a master object is <a href="#stream.close"><tt>close</tt></a>.
449</p>
450
451<p class="return">
452In 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>
461Datagram Unix domain sockets behave like UDP sockets (see
462<a href="udp.html">UDP</a>): a socket starts out unconnected, and can
463optionally be turned into a connected socket with
464<a href="#dgram.connect"><tt>connect</tt></a> for repeated exchanges with
465a single peer.
466</p>
467
468<!-- dgram.bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
469
470<p class="name" id="dgram.bind">
471unconnected:<b>bind(</b>path<b>)</b><br>
472unconnected:<b>setsockname(</b>path<b>)</b>
473</p>
474
475<p class="description">
476Binds 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
478required if you want other processes to be able to
479<a href="#dgram.sendto"><tt>sendto</tt></a> this object; it is not
480required 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">
485In case of success, the method returns 1. In case of error, the method
486returns <b><tt>nil</tt></b> followed by an error message.
487</p>
488
489<!-- dgram.close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
490
491<p class="name" id="dgram.close">
492connected:<b>close()</b><br>
493unconnected:<b>close()</b>
494</p>
495
496<p class="description">
497Closes a datagram Unix domain object.
498</p>
499
500<p class="note">
501Note: Closing a socket does not remove the bound path from the file
502system. Delete the socket file yourself (e.g. <tt>os.remove(path)</tt>)
503once you are done with it.
504</p>
505
506<p class="note">
507Note: Garbage-collected objects are automatically closed before
508destruction.
509</p>
510
511<!-- dgram.connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
512
513<p class="name" id="dgram.connect">
514connected:<b>connect(</b>path<b>)</b><br>
515unconnected:<b>connect(</b>path<b>)</b><br>
516connected:<b>setpeername(</b>path<b>)</b><br>
517unconnected:<b>setpeername(</b>path<b>)</b>
518</p>
519
520<p class="description">
521Sets (or changes) the peer of a datagram object, turning an unconnected
522object 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">
531In case of error, the method returns <b><tt>nil</tt></b> followed by an
532error message. In case of success, the method returns 1.
533</p>
534
535<p class="note">
536Note: Unlike <a href="udp.html#setpeername"><tt>udp:setpeername</tt></a>,
537there is no '<tt>*</tt>' path to dissolve the peer association back to an
538unconnected socket.
539</p>
540
541<!-- dgram.dirty ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
542
543<p class="name" id="dgram.dirty">
544connected:<b>dirty()</b><br>
545unconnected:<b>dirty()</b>
546</p>
547
548<p class="description">
549Check the read buffer status.
550</p>
551
552<p class="return">
553Always returns <tt>false</tt>. Datagram objects do not keep a read
554buffer.
555</p>
556
557<p class="note">
558Note: <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">
564connected:<b>getfd()</b><br>
565unconnected:<b>getfd()</b>
566</p>
567
568<p class="description">
569Returns the underlying socket descriptor or handle associated to the
570object.
571</p>
572
573<p class="return">
574The descriptor or handle.
575</p>
576
577<p class="note">
578Note: <b>This is an internal method. Unlikely to be portable. Use at your
579own risk.</b>
580</p>
581
582<!-- dgram.getsockname +++++++++++++++++++++++++++++++++++++++++++++++++ -->
583
584<p class="name" id="dgram.getsockname">
585connected:<b>getsockname()</b><br>
586unconnected:<b>getsockname()</b>
587</p>
588
589<p class="description">
590Returns the local path the object is bound to.
591</p>
592
593<p class="return">
594The method returns a string with the local path. In case of error, the
595method returns <b><tt>nil</tt></b>.
596</p>
597
598<!-- dgram.gettimeout +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
599
600<p class="name" id="dgram.gettimeout">
601connected:<b>gettimeout()</b><br>
602unconnected:<b>gettimeout()</b>
603</p>
604
605<p class="description">
606Returns the current timeout value.
607</p>
608
609<!-- dgram.receive +++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
610
611<p class="name" id="dgram.receive">
612connected:<b>receive(</b>[size]<b>)</b><br>
613unconnected:<b>receive(</b>[size]<b>)</b>
614</p>
615
616<p class="description">
617Receives a datagram from the object. If the object is connected, only
618datagrams coming from the peer are accepted.
619</p>
620
621<p class="parameters">
622The optional <tt>size</tt> parameter specifies the maximum size of the
623datagram to be retrieved (defaults to 8192 bytes).
624</p>
625
626<p class="return">
627In case of success, the method returns the received datagram, which may
628be the empty string (a valid zero-length datagram, not end-of-stream). In
629case of timeout, the method returns <b><tt>nil</tt></b> followed by the
630string '<tt>timeout</tt>'.
631</p>
632
633<!-- dgram.receivefrom +++++++++++++++++++++++++++++++++++++++++++++++++ -->
634
635<p class="name" id="dgram.receivefrom">
636unconnected:<b>receivefrom(</b>[size]<b>)</b>
637</p>
638
639<p class="description">
640Works exactly as <a href="#dgram.receive"><tt>receive</tt></a>, except it
641also returns the sender's path as a second return value.
642</p>
643
644<p class="return">
645In case of success, the method returns the received datagram followed by
646the sender's path (the empty string if the sender's socket was not
647bound). In case of timeout, the method returns <b><tt>nil</tt></b>
648followed by the string '<tt>timeout</tt>'.
649</p>
650
651<!-- dgram.send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
652
653<p class="name" id="dgram.send">
654connected:<b>send(</b>datagram<b>)</b>
655</p>
656
657<p class="description">
658Sends a datagram to the peer of a connected object.
659</p>
660
661<p class="return">
662If successful, the method returns the number of bytes sent. In case of
663error, the method returns <b><tt>nil</tt></b> followed by an error
664message (the string '<tt>refused</tt>' if the peer's socket is not
665accepting datagrams).
666</p>
667
668<!-- dgram.sendto +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
669
670<p class="name" id="dgram.sendto">
671unconnected:<b>sendto(</b>datagram, path<b>)</b>
672</p>
673
674<p class="description">
675Sends 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>
680is the file system path of the recipient.
681</p>
682
683<p class="return">
684If successful, the method returns the number of bytes sent. In case of
685error, the method returns <b><tt>nil</tt></b> followed by an error
686message (the string '<tt>refused</tt>' if the recipient's socket is not
687accepting datagrams).
688</p>
689
690<!-- dgram.setfd ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
691
692<p class="name" id="dgram.setfd">
693connected:<b>setfd(</b>fd<b>)</b><br>
694unconnected:<b>setfd(</b>fd<b>)</b>
695</p>
696
697<p class="description">
698Sets the underlying socket descriptor or handle associated to the object.
699</p>
700
701<p class="return">
702No return value.
703</p>
704
705<p class="note">
706Note: <b>This is an internal method. Unlikely to be portable. Use at your
707own risk.</b>
708</p>
709
710<!-- dgram.setoption +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
711
712<p class="name" id="dgram.setoption">
713connected:<b>setoption(</b>option [, value]<b>)</b><br>
714unconnected:<b>setoption(</b>option [, value]<b>)</b>
715</p>
716
717<p class="description">
718Sets 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
727addresses supplied in a <a href="#dgram.bind"><tt>bind</tt></a> call
728should allow reuse of local addresses. Receives a boolean value.</li>
729</ul>
730
731<p class="return">
732The method returns 1 in case of success, or <b><tt>nil</tt></b> followed
733by an error message otherwise.
734</p>
735
736<!-- dgram.settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
737
738<p class="name" id="dgram.settimeout">
739connected:<b>settimeout(</b>value<b>)</b><br>
740unconnected:<b>settimeout(</b>value<b>)</b>
741</p>
742
743<p class="description">
744Changes 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
748affects <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">
755unix.<b>dgram()</b>
756</p>
757
758<p class="description">
759Creates and returns an unconnected datagram Unix domain object.
760Unconnected 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
770connected object.
771</p>
772
773<p class="return">
774In case of success, a new unconnected datagram object is returned. In
775case of error, <b><tt>nil</tt></b> is returned, followed by an error
776message.
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> &middot;
786<a href="index.html#download">download</a> &middot;
787<a href="installation.html">installation</a> &middot;
788<a href="introduction.html">introduction</a> &middot;
789<a href="reference.html">reference</a>
790</p>
791</center>
792</div>
793
794</body>
795</html>