diff options
author | Diego Nehab <diego.nehab@gmail.com> | 2016-03-04 15:36:32 -0300 |
---|---|---|
committer | Diego Nehab <diego.nehab@gmail.com> | 2016-03-04 15:36:32 -0300 |
commit | 944305dc21350fd2ec32a9552d893da86894fd62 (patch) | |
tree | 82948c24dade5e0da6924ab5e706f146bce4692a | |
parent | cdce73b226cc4da6a073b79bec02a6780d32ff1a (diff) | |
download | luasocket-944305dc21350fd2ec32a9552d893da86894fd62.tar.gz luasocket-944305dc21350fd2ec32a9552d893da86894fd62.tar.bz2 luasocket-944305dc21350fd2ec32a9552d893da86894fd62.zip |
Added gettimeout for completeness.
Also documented.
Rordered manuals so order is alphabetical.
-rw-r--r-- | doc/mime.html | 59 | ||||
-rw-r--r-- | doc/reference.html | 2 | ||||
-rw-r--r-- | doc/smtp.html | 235 | ||||
-rw-r--r-- | doc/socket.html | 70 | ||||
-rw-r--r-- | doc/tcp.html | 283 | ||||
-rw-r--r-- | doc/udp.html | 431 | ||||
-rw-r--r-- | src/tcp.c | 8 | ||||
-rw-r--r-- | src/timeout.c | 10 | ||||
-rw-r--r-- | src/timeout.h | 1 | ||||
-rw-r--r-- | src/udp.c | 7 |
10 files changed, 587 insertions, 519 deletions
diff --git a/doc/mime.html b/doc/mime.html index ae136fd..8cb3507 100644 --- a/doc/mime.html +++ b/doc/mime.html | |||
@@ -72,34 +72,6 @@ local mime = require("mime") | |||
72 | 72 | ||
73 | <h3 id=high>High-level filters</h3> | 73 | <h3 id=high>High-level filters</h3> |
74 | 74 | ||
75 | <!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
76 | |||
77 | <p class=name id="normalize"> | ||
78 | mime.<b>normalize(</b>[marker]<b>)</b> | ||
79 | </p> | ||
80 | |||
81 | <p class=description> | ||
82 | Converts most common end-of-line markers to a specific given marker. | ||
83 | </p> | ||
84 | |||
85 | <p class=parameters> | ||
86 | <tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic | ||
87 | end-of-line marker defined by the MIME standard. | ||
88 | </p> | ||
89 | |||
90 | <p class=return> | ||
91 | The function returns a filter that performs the conversion. | ||
92 | </p> | ||
93 | |||
94 | <p class=note> | ||
95 | Note: There is no perfect solution to this problem. Different end-of-line | ||
96 | markers are an evil that will probably plague developers forever. | ||
97 | This function, however, will work perfectly for text created with any of | ||
98 | the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), | ||
99 | or the DOS (CRLF) conventions. Even if the data has mixed end-of-line | ||
100 | markers, the function will still work well, although it doesn't | ||
101 | guarantee that the number of empty lines will be correct. | ||
102 | </p> | ||
103 | 75 | ||
104 | <!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 76 | <!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
105 | 77 | ||
@@ -159,6 +131,35 @@ base64 = ltn12.filter.chain( | |||
159 | ) | 131 | ) |
160 | </pre> | 132 | </pre> |
161 | 133 | ||
134 | <!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
135 | |||
136 | <p class=name id="normalize"> | ||
137 | mime.<b>normalize(</b>[marker]<b>)</b> | ||
138 | </p> | ||
139 | |||
140 | <p class=description> | ||
141 | Converts most common end-of-line markers to a specific given marker. | ||
142 | </p> | ||
143 | |||
144 | <p class=parameters> | ||
145 | <tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic | ||
146 | end-of-line marker defined by the MIME standard. | ||
147 | </p> | ||
148 | |||
149 | <p class=return> | ||
150 | The function returns a filter that performs the conversion. | ||
151 | </p> | ||
152 | |||
153 | <p class=note> | ||
154 | Note: There is no perfect solution to this problem. Different end-of-line | ||
155 | markers are an evil that will probably plague developers forever. | ||
156 | This function, however, will work perfectly for text created with any of | ||
157 | the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), | ||
158 | or the DOS (CRLF) conventions. Even if the data has mixed end-of-line | ||
159 | markers, the function will still work well, although it doesn't | ||
160 | guarantee that the number of empty lines will be correct. | ||
161 | </p> | ||
162 | |||
162 | <!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 163 | <!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
163 | 164 | ||
164 | <p class=name id="stuff"> | 165 | <p class=name id="stuff"> |
@@ -466,7 +467,7 @@ marker. | |||
466 | <p> | 467 | <p> |
467 | <small> | 468 | <small> |
468 | Last modified by Diego Nehab on <br> | 469 | Last modified by Diego Nehab on <br> |
469 | Thu Apr 20 00:25:44 EDT 2006 | 470 | Fri Mar 4 15:19:17 BRT 2016 |
470 | </small> | 471 | </small> |
471 | </p> | 472 | </p> |
472 | </center> | 473 | </center> |
diff --git a/doc/reference.html b/doc/reference.html index 878e7d2..287dc19 100644 --- a/doc/reference.html +++ b/doc/reference.html | |||
@@ -187,6 +187,7 @@ Support, Manual"> | |||
187 | <a href="tcp.html#getpeername">getpeername</a>, | 187 | <a href="tcp.html#getpeername">getpeername</a>, |
188 | <a href="tcp.html#getsockname">getsockname</a>, | 188 | <a href="tcp.html#getsockname">getsockname</a>, |
189 | <a href="tcp.html#getstats">getstats</a>, | 189 | <a href="tcp.html#getstats">getstats</a>, |
190 | <a href="tcp.html#gettimeout">gettimeout</a>, | ||
190 | <a href="tcp.html#listen">listen</a>, | 191 | <a href="tcp.html#listen">listen</a>, |
191 | <a href="tcp.html#receive">receive</a>, | 192 | <a href="tcp.html#receive">receive</a>, |
192 | <a href="tcp.html#send">send</a>, | 193 | <a href="tcp.html#send">send</a>, |
@@ -207,6 +208,7 @@ Support, Manual"> | |||
207 | <a href="udp.html#getoption">getoption</a>, | 208 | <a href="udp.html#getoption">getoption</a>, |
208 | <a href="udp.html#getpeername">getpeername</a>, | 209 | <a href="udp.html#getpeername">getpeername</a>, |
209 | <a href="udp.html#getsockname">getsockname</a>, | 210 | <a href="udp.html#getsockname">getsockname</a>, |
211 | <a href="udp.html#gettimeout">gettimeout</a>, | ||
210 | <a href="udp.html#receive">receive</a>, | 212 | <a href="udp.html#receive">receive</a>, |
211 | <a href="udp.html#receivefrom">receivefrom</a>, | 213 | <a href="udp.html#receivefrom">receivefrom</a>, |
212 | <a href="udp.html#send">send</a>, | 214 | <a href="udp.html#send">send</a>, |
diff --git a/doc/smtp.html b/doc/smtp.html index bbbff80..600ec37 100644 --- a/doc/smtp.html +++ b/doc/smtp.html | |||
@@ -114,6 +114,124 @@ the SMTP module: | |||
114 | <li> <tt>ZONE</tt>: default time zone. | 114 | <li> <tt>ZONE</tt>: default time zone. |
115 | </ul> | 115 | </ul> |
116 | 116 | ||
117 | <!-- message ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
118 | |||
119 | <p class=name id=message> | ||
120 | smtp.<b>message(</b>mesgt<b>)</b> | ||
121 | </p> | ||
122 | |||
123 | <p class=description> | ||
124 | Returns a <em>simple</em> | ||
125 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep). | ||
126 | </p> | ||
127 | |||
128 | <p class=parameters> | ||
129 | The only parameter of the function is a table describing the message. | ||
130 | <tt>Mesgt</tt> has the following form (notice the recursive structure): | ||
131 | </p> | ||
132 | |||
133 | <blockquote> | ||
134 | <table summary="Mesgt table structure"> | ||
135 | <tr><td><tt> | ||
136 | mesgt = {<br> | ||
137 | headers = <i>header-table</i>,<br> | ||
138 | body = <i>LTN12 source</i> or <i>string</i> or | ||
139 | <i>multipart-mesgt</i><br> | ||
140 | }<br> | ||
141 | <br> | ||
142 | multipart-mesgt = {<br> | ||
143 | [preamble = <i>string</i>,]<br> | ||
144 | [1] = <i>mesgt</i>,<br> | ||
145 | [2] = <i>mesgt</i>,<br> | ||
146 | ...<br> | ||
147 | [<i>n</i>] = <i>mesgt</i>,<br> | ||
148 | [epilogue = <i>string</i>,]<br> | ||
149 | }<br> | ||
150 | </tt></td></tr> | ||
151 | </table> | ||
152 | </blockquote> | ||
153 | |||
154 | <p class=parameters> | ||
155 | For a simple message, all that is needed is a set of <tt>headers</tt> | ||
156 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string | ||
157 | or as a <em>simple</em> | ||
158 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
159 | source. For multipart messages, the body is a table that | ||
160 | recursively defines each part as an independent message, plus an optional | ||
161 | <tt>preamble</tt> and <tt>epilogue</tt>. | ||
162 | </p> | ||
163 | |||
164 | <p class=return> | ||
165 | The function returns a <em>simple</em> | ||
166 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
167 | source that produces the | ||
168 | message contents as defined by <tt>mesgt</tt>, chunk by chunk. | ||
169 | Hopefully, the following | ||
170 | example will make things clear. When in doubt, refer to the appropriate RFC | ||
171 | as listed in the introduction. </p> | ||
172 | |||
173 | <pre class=example> | ||
174 | -- load the smtp support and its friends | ||
175 | local smtp = require("socket.smtp") | ||
176 | local mime = require("mime") | ||
177 | local ltn12 = require("ltn12") | ||
178 | |||
179 | -- creates a source to send a message with two parts. The first part is | ||
180 | -- plain text, the second part is a PNG image, encoded as base64. | ||
181 | source = smtp.message{ | ||
182 | headers = { | ||
183 | -- Remember that headers are *ignored* by smtp.send. | ||
184 | from = "Sicrano de Oliveira <sicrano@example.com>", | ||
185 | to = "Fulano da Silva <fulano@example.com>", | ||
186 | subject = "Here is a message with attachments" | ||
187 | }, | ||
188 | body = { | ||
189 | preamble = "If your client doesn't understand attachments, \r\n" .. | ||
190 | "it will still display the preamble and the epilogue.\r\n" .. | ||
191 | "Preamble will probably appear even in a MIME enabled client.", | ||
192 | -- first part: no headers means plain text, us-ascii. | ||
193 | -- The mime.eol low-level filter normalizes end-of-line markers. | ||
194 | [1] = { | ||
195 | body = mime.eol(0, [[ | ||
196 | Lines in a message body should always end with CRLF. | ||
197 | The smtp module will *NOT* perform translation. However, the | ||
198 | send function *DOES* perform SMTP stuffing, whereas the message | ||
199 | function does *NOT*. | ||
200 | ]]) | ||
201 | }, | ||
202 | -- second part: headers describe content to be a png image, | ||
203 | -- sent under the base64 transfer content encoding. | ||
204 | -- notice that nothing happens until the message is actually sent. | ||
205 | -- small chunks are loaded into memory right before transmission and | ||
206 | -- translation happens on the fly. | ||
207 | [2] = { | ||
208 | headers = { | ||
209 | ["content-type"] = 'image/png; name="image.png"', | ||
210 | ["content-disposition"] = 'attachment; filename="image.png"', | ||
211 | ["content-description"] = 'a beautiful image', | ||
212 | ["content-transfer-encoding"] = "BASE64" | ||
213 | }, | ||
214 | body = ltn12.source.chain( | ||
215 | ltn12.source.file(io.open("image.png", "rb")), | ||
216 | ltn12.filter.chain( | ||
217 | mime.encode("base64"), | ||
218 | mime.wrap() | ||
219 | ) | ||
220 | ) | ||
221 | }, | ||
222 | epilogue = "This might also show up, but after the attachments" | ||
223 | } | ||
224 | } | ||
225 | |||
226 | -- finally send it | ||
227 | r, e = smtp.send{ | ||
228 | from = "<sicrano@example.com>", | ||
229 | rcpt = "<fulano@example.com>", | ||
230 | source = source, | ||
231 | } | ||
232 | </pre> | ||
233 | |||
234 | |||
117 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 235 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
118 | 236 | ||
119 | <p class=name id=send> | 237 | <p class=name id=send> |
@@ -275,123 +393,6 @@ r, e = smtp.send{ | |||
275 | } | 393 | } |
276 | </pre> | 394 | </pre> |
277 | 395 | ||
278 | <!-- message ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
279 | |||
280 | <p class=name id=message> | ||
281 | smtp.<b>message(</b>mesgt<b>)</b> | ||
282 | </p> | ||
283 | |||
284 | <p class=description> | ||
285 | Returns a <em>simple</em> | ||
286 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep). | ||
287 | </p> | ||
288 | |||
289 | <p class=parameters> | ||
290 | The only parameter of the function is a table describing the message. | ||
291 | <tt>Mesgt</tt> has the following form (notice the recursive structure): | ||
292 | </p> | ||
293 | |||
294 | <blockquote> | ||
295 | <table summary="Mesgt table structure"> | ||
296 | <tr><td><tt> | ||
297 | mesgt = {<br> | ||
298 | headers = <i>header-table</i>,<br> | ||
299 | body = <i>LTN12 source</i> or <i>string</i> or | ||
300 | <i>multipart-mesgt</i><br> | ||
301 | }<br> | ||
302 | <br> | ||
303 | multipart-mesgt = {<br> | ||
304 | [preamble = <i>string</i>,]<br> | ||
305 | [1] = <i>mesgt</i>,<br> | ||
306 | [2] = <i>mesgt</i>,<br> | ||
307 | ...<br> | ||
308 | [<i>n</i>] = <i>mesgt</i>,<br> | ||
309 | [epilogue = <i>string</i>,]<br> | ||
310 | }<br> | ||
311 | </tt></td></tr> | ||
312 | </table> | ||
313 | </blockquote> | ||
314 | |||
315 | <p class=parameters> | ||
316 | For a simple message, all that is needed is a set of <tt>headers</tt> | ||
317 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string | ||
318 | or as a <em>simple</em> | ||
319 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
320 | source. For multipart messages, the body is a table that | ||
321 | recursively defines each part as an independent message, plus an optional | ||
322 | <tt>preamble</tt> and <tt>epilogue</tt>. | ||
323 | </p> | ||
324 | |||
325 | <p class=return> | ||
326 | The function returns a <em>simple</em> | ||
327 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
328 | source that produces the | ||
329 | message contents as defined by <tt>mesgt</tt>, chunk by chunk. | ||
330 | Hopefully, the following | ||
331 | example will make things clear. When in doubt, refer to the appropriate RFC | ||
332 | as listed in the introduction. </p> | ||
333 | |||
334 | <pre class=example> | ||
335 | -- load the smtp support and its friends | ||
336 | local smtp = require("socket.smtp") | ||
337 | local mime = require("mime") | ||
338 | local ltn12 = require("ltn12") | ||
339 | |||
340 | -- creates a source to send a message with two parts. The first part is | ||
341 | -- plain text, the second part is a PNG image, encoded as base64. | ||
342 | source = smtp.message{ | ||
343 | headers = { | ||
344 | -- Remember that headers are *ignored* by smtp.send. | ||
345 | from = "Sicrano de Oliveira <sicrano@example.com>", | ||
346 | to = "Fulano da Silva <fulano@example.com>", | ||
347 | subject = "Here is a message with attachments" | ||
348 | }, | ||
349 | body = { | ||
350 | preamble = "If your client doesn't understand attachments, \r\n" .. | ||
351 | "it will still display the preamble and the epilogue.\r\n" .. | ||
352 | "Preamble will probably appear even in a MIME enabled client.", | ||
353 | -- first part: no headers means plain text, us-ascii. | ||
354 | -- The mime.eol low-level filter normalizes end-of-line markers. | ||
355 | [1] = { | ||
356 | body = mime.eol(0, [[ | ||
357 | Lines in a message body should always end with CRLF. | ||
358 | The smtp module will *NOT* perform translation. However, the | ||
359 | send function *DOES* perform SMTP stuffing, whereas the message | ||
360 | function does *NOT*. | ||
361 | ]]) | ||
362 | }, | ||
363 | -- second part: headers describe content to be a png image, | ||
364 | -- sent under the base64 transfer content encoding. | ||
365 | -- notice that nothing happens until the message is actually sent. | ||
366 | -- small chunks are loaded into memory right before transmission and | ||
367 | -- translation happens on the fly. | ||
368 | [2] = { | ||
369 | headers = { | ||
370 | ["content-type"] = 'image/png; name="image.png"', | ||
371 | ["content-disposition"] = 'attachment; filename="image.png"', | ||
372 | ["content-description"] = 'a beautiful image', | ||
373 | ["content-transfer-encoding"] = "BASE64" | ||
374 | }, | ||
375 | body = ltn12.source.chain( | ||
376 | ltn12.source.file(io.open("image.png", "rb")), | ||
377 | ltn12.filter.chain( | ||
378 | mime.encode("base64"), | ||
379 | mime.wrap() | ||
380 | ) | ||
381 | ) | ||
382 | }, | ||
383 | epilogue = "This might also show up, but after the attachments" | ||
384 | } | ||
385 | } | ||
386 | |||
387 | -- finally send it | ||
388 | r, e = smtp.send{ | ||
389 | from = "<sicrano@example.com>", | ||
390 | rcpt = "<fulano@example.com>", | ||
391 | source = source, | ||
392 | } | ||
393 | </pre> | ||
394 | |||
395 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 396 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
396 | 397 | ||
397 | <div class=footer> | 398 | <div class=footer> |
diff --git a/doc/socket.html b/doc/socket.html index a99d71b..35f8391 100644 --- a/doc/socket.html +++ b/doc/socket.html | |||
@@ -51,6 +51,30 @@ 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 | <!-- headers.canonic ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
55 | |||
56 | <p class=name id="headers.canonic"> | ||
57 | socket.headers.<b>canonic</b></p> | ||
58 | |||
59 | <p> The <tt>socket.headers.canonic</tt> table | ||
60 | is used by the HTTP and SMTP modules to translate from | ||
61 | lowercase field names back into their canonic | ||
62 | capitalization. When a lowercase field name exists as a key | ||
63 | in this table, the associated value is substituted in | ||
64 | whenever the field name is sent out. | ||
65 | </p> | ||
66 | |||
67 | <p> | ||
68 | You can obtain the <tt>headers</tt> namespace if case run-time | ||
69 | modifications are required by running: | ||
70 | </p> | ||
71 | |||
72 | <pre class=example> | ||
73 | -- loads the headers module | ||
74 | local headers = require("headers") | ||
75 | </pre> | ||
76 | |||
77 | |||
54 | <!-- bind ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 78 | <!-- bind ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
55 | 79 | ||
56 | <p class=name id=bind> | 80 | <p class=name id=bind> |
@@ -129,29 +153,6 @@ t = socket.gettime() | |||
129 | print(socket.gettime() - t .. " seconds elapsed") | 153 | print(socket.gettime() - t .. " seconds elapsed") |
130 | </pre> | 154 | </pre> |
131 | 155 | ||
132 | <!-- socket.headers ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
133 | |||
134 | <p class=name id="headers.canonic"> | ||
135 | socket.headers.<b>canonic</b></p> | ||
136 | |||
137 | <p> The <tt>socket.headers.canonic</tt> table | ||
138 | is used by the HTTP and SMTP modules to translate from | ||
139 | lowercase field names back into their canonic | ||
140 | capitalization. When a lowercase field name exists as a key | ||
141 | in this table, the associated value is substituted in | ||
142 | whenever the field name is sent out. | ||
143 | </p> | ||
144 | |||
145 | <p> | ||
146 | You can obtain the <tt>headers</tt> namespace if case run-time | ||
147 | modifications are required by running: | ||
148 | </p> | ||
149 | |||
150 | <pre class=example> | ||
151 | -- loads the headers module | ||
152 | local headers = require("headers") | ||
153 | </pre> | ||
154 | |||
155 | <!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 156 | <!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
156 | 157 | ||
157 | <p class=name id=newtry> | 158 | <p class=name id=newtry> |
@@ -283,6 +284,18 @@ it to <tt>select</tt>, it will be ignored. | |||
283 | <b>Using select with non-socket objects</b>: Any object that implements <tt>getfd</tt> and <tt>dirty</tt> can be used with <tt>select</tt>, allowing objects from other libraries to be used within a <tt>socket.select</tt> driven loop. | 284 | <b>Using select with non-socket objects</b>: Any object that implements <tt>getfd</tt> and <tt>dirty</tt> can be used with <tt>select</tt>, allowing objects from other libraries to be used within a <tt>socket.select</tt> driven loop. |
284 | </p> | 285 | </p> |
285 | 286 | ||
287 | <!-- setsize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
288 | |||
289 | <p class=name id=setsize> | ||
290 | socket.<b>_SETSIZE</b> | ||
291 | </p> | ||
292 | |||
293 | <p class=description> | ||
294 | The maximum number of sockets that the <a | ||
295 | href=#select><tt>select</tt></a> function can handle. | ||
296 | </p> | ||
297 | |||
298 | |||
286 | <!-- sink ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 299 | <!-- sink ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
287 | 300 | ||
288 | <p class=name id=sink> | 301 | <p class=name id=sink> |
@@ -390,17 +403,6 @@ side closes the connection. | |||
390 | The function returns a source with the appropriate behavior. | 403 | The function returns a source with the appropriate behavior. |
391 | </p> | 404 | </p> |
392 | 405 | ||
393 | <!-- setsize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
394 | |||
395 | <p class=name id=setsize> | ||
396 | socket.<b>_SETSIZE</b> | ||
397 | </p> | ||
398 | |||
399 | <p class=description> | ||
400 | The maximum number of sockets that the <a | ||
401 | href=#select><tt>select</tt></a> function can handle. | ||
402 | </p> | ||
403 | |||
404 | <!-- socketinvalid ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 406 | <!-- socketinvalid ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
405 | 407 | ||
406 | <p class=name id=socketinvalid> | 408 | <p class=name id=socketinvalid> |
diff --git a/doc/tcp.html b/doc/tcp.html index c86853d..c6c6eb2 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
@@ -38,84 +38,6 @@ | |||
38 | 38 | ||
39 | <h2 id="tcp">TCP</h2> | 39 | <h2 id="tcp">TCP</h2> |
40 | 40 | ||
41 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
42 | |||
43 | <p class=name id="socket.tcp"> | ||
44 | socket.<b>tcp()</b> | ||
45 | </p> | ||
46 | |||
47 | <p class=description> | ||
48 | Creates and returns an TCP master object. A master object can | ||
49 | be transformed into a server object with the method | ||
50 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
51 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
52 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
53 | method supported by a master object is the | ||
54 | <a href=#close><tt>close</tt></a> method.</p> | ||
55 | |||
56 | <p class=return> | ||
57 | In case of success, a new master object is returned. In case of error, | ||
58 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
59 | </p> | ||
60 | |||
61 | <p class=note> | ||
62 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
63 | <a href=#bind><tt>bind</tt></a> or <a | ||
64 | href=#bind><tt>connect</tt></a>, depending on the address | ||
65 | family obtained from the resolver. | ||
66 | </p> | ||
67 | |||
68 | <p class=note> | ||
69 | Note: Before the choice between IPv4 and IPv6 happens, | ||
70 | the internal socket object is invalid and therefore <a | ||
71 | href=#setoption><tt>setoption</tt></a> will fail. | ||
72 | </p> | ||
73 | |||
74 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
75 | |||
76 | <p class=name id="socket.tcp4"> | ||
77 | socket.<b>tcp4()</b> | ||
78 | </p> | ||
79 | |||
80 | <p class=description> | ||
81 | Creates and returns an IPv4 TCP master object. A master object can | ||
82 | be transformed into a server object with the method | ||
83 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
84 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
85 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
86 | method supported by a master object is the | ||
87 | <a href=#close><tt>close</tt></a> method.</p> | ||
88 | |||
89 | <p class=return> | ||
90 | In case of success, a new master object is returned. In case of error, | ||
91 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
92 | </p> | ||
93 | |||
94 | <!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
95 | |||
96 | <p class=name id="socket.tcp6"> | ||
97 | socket.<b>tcp6()</b> | ||
98 | </p> | ||
99 | |||
100 | <p class=description> | ||
101 | Creates and returns an IPv6 TCP master object. A master object can | ||
102 | be transformed into a server object with the method | ||
103 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
104 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
105 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
106 | method supported by a master object is the | ||
107 | <a href=#close><tt>close</tt></a> method.</p> | ||
108 | |||
109 | <p class=return> | ||
110 | In case of success, a new master object is returned. In case of error, | ||
111 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
112 | </p> | ||
113 | |||
114 | <p class=note> | ||
115 | Note: The TCP object returned will have the option | ||
116 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. | ||
117 | </p> | ||
118 | |||
119 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 41 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
120 | 42 | ||
121 | <p class=name id="accept"> | 43 | <p class=name id="accept"> |
@@ -252,6 +174,78 @@ first success or until the last failure. If the timeout was | |||
252 | set to zero, only the first address is tried. | 174 | set to zero, only the first address is tried. |
253 | </p> | 175 | </p> |
254 | 176 | ||
177 | <!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
178 | |||
179 | <p class=name id="dirty"> | ||
180 | master:<b>dirty()</b><br> | ||
181 | client:<b>dirty()</b><br> | ||
182 | server:<b>dirty()</b> | ||
183 | </p> | ||
184 | |||
185 | <p class=description> | ||
186 | Check the read buffer status. | ||
187 | </p> | ||
188 | |||
189 | <p class=return> | ||
190 | Returns <tt>true</tt> if there is any data in the read buffer, <tt>false</tt> otherwise. | ||
191 | </p> | ||
192 | |||
193 | <p class=note> | ||
194 | Note: <b>This is an internal method, use at your own risk.</b> | ||
195 | </p> | ||
196 | |||
197 | |||
198 | <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
199 | |||
200 | <p class=name id="getfd"> | ||
201 | master:<b>getfd()</b><br> | ||
202 | client:<b>getfd()</b><br> | ||
203 | server:<b>getfd()</b> | ||
204 | </p> | ||
205 | |||
206 | <p class=description> | ||
207 | Returns the underling socket descriptor or handle associated to the object. | ||
208 | </p> | ||
209 | |||
210 | <p class=return> | ||
211 | The descriptor or handle. In case the object has been closed, the return will be -1. | ||
212 | </p> | ||
213 | |||
214 | <p class=note> | ||
215 | Note: <b>This is an internal method. Unlikely to be | ||
216 | portable. Use at your own risk. </b> | ||
217 | </p> | ||
218 | |||
219 | |||
220 | <!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
221 | |||
222 | <p class=name id="getoption"> | ||
223 | client:<b>getoption(</b>option)</b><br> | ||
224 | server:<b>getoption(</b>option)</b> | ||
225 | </p> | ||
226 | |||
227 | <p class=description> | ||
228 | Gets options for the TCP object. | ||
229 | See <a href=#setoption><tt>setoption</tt></a> for description of the | ||
230 | option names and values. | ||
231 | </p> | ||
232 | |||
233 | <p class=parameters> | ||
234 | <tt>Option</tt> is a string with the option name. | ||
235 | <ul> | ||
236 | |||
237 | <li> '<tt>keepalive</tt>' | ||
238 | <li> '<tt>linger</tt>' | ||
239 | <li> '<tt>reuseaddr</tt>' | ||
240 | <li> '<tt>tcp-nodelay</tt>' | ||
241 | </ul> | ||
242 | |||
243 | <p class=return> | ||
244 | The method returns the option <tt>value</tt> in case of success, or | ||
245 | <b><tt>nil</tt></b> followed by an error message otherwise. | ||
246 | </p> | ||
247 | |||
248 | |||
255 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 249 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
256 | 250 | ||
257 | <p class=name id="getpeername"> | 251 | <p class=name id="getpeername"> |
@@ -310,6 +304,20 @@ The method returns the number of bytes received, the number of bytes sent, | |||
310 | and the age of the socket object in seconds. | 304 | and the age of the socket object in seconds. |
311 | </p> | 305 | </p> |
312 | 306 | ||
307 | <!-- gettimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
308 | |||
309 | <p class=name id="gettimeout"> | ||
310 | master:<b>gettimeout()</b><br> | ||
311 | client:<b>gettimeout()</b><br> | ||
312 | server:<b>gettimeout()</b> | ||
313 | </p> | ||
314 | |||
315 | <p class=description> | ||
316 | Returns the current block timeout followed by the curent | ||
317 | total timeout. | ||
318 | </p> | ||
319 | |||
320 | |||
313 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 321 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
314 | 322 | ||
315 | <p class=name id="listen"> | 323 | <p class=name id="listen"> |
@@ -483,34 +491,6 @@ followed by an error message otherwise. | |||
483 | Note: The descriptions above come from the man pages. | 491 | Note: The descriptions above come from the man pages. |
484 | </p> | 492 | </p> |
485 | 493 | ||
486 | <!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
487 | |||
488 | <p class=name id="getoption"> | ||
489 | client:<b>getoption(</b>option)</b><br> | ||
490 | server:<b>getoption(</b>option)</b> | ||
491 | </p> | ||
492 | |||
493 | <p class=description> | ||
494 | Gets options for the TCP object. | ||
495 | See <a href=#setoption><tt>setoption</tt></a> for description of the | ||
496 | option names and values. | ||
497 | </p> | ||
498 | |||
499 | <p class=parameters> | ||
500 | <tt>Option</tt> is a string with the option name. | ||
501 | <ul> | ||
502 | |||
503 | <li> '<tt>keepalive</tt>' | ||
504 | <li> '<tt>linger</tt>' | ||
505 | <li> '<tt>reuseaddr</tt>' | ||
506 | <li> '<tt>tcp-nodelay</tt>' | ||
507 | </ul> | ||
508 | |||
509 | <p class=return> | ||
510 | The method returns the option <tt>value</tt> in case of success, or | ||
511 | <b><tt>nil</tt></b> followed by an error message otherwise. | ||
512 | </p> | ||
513 | |||
514 | <!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 494 | <!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
515 | 495 | ||
516 | <p class=name id="setstats"> | 496 | <p class=name id="setstats"> |
@@ -615,66 +595,107 @@ This is the default mode; | |||
615 | This function returns 1. | 595 | This function returns 1. |
616 | </p> | 596 | </p> |
617 | 597 | ||
618 | <!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 598 | <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
619 | 599 | ||
620 | <p class=name id="dirty"> | 600 | <p class=name id="setfd"> |
621 | master:<b>dirty()</b><br> | 601 | master:<b>setfd(</b>fd<b>)</b><br> |
622 | client:<b>dirty()</b><br> | 602 | client:<b>setfd(</b>fd<b>)</b><br> |
623 | server:<b>dirty()</b> | 603 | server:<b>setfd(</b>fd<b>)</b> |
624 | </p> | 604 | </p> |
625 | 605 | ||
626 | <p class=description> | 606 | <p class=description> |
627 | Check the read buffer status. | 607 | Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made. |
628 | </p> | 608 | </p> |
629 | 609 | ||
630 | <p class=return> | 610 | <p class=return> |
631 | Returns <tt>true</tt> if there is any data in the read buffer, <tt>false</tt> otherwise. | 611 | No return value. |
632 | </p> | 612 | </p> |
633 | 613 | ||
634 | <p class=note> | 614 | <p class=note> |
635 | Note: <b>This is an internal method, any use is unlikely to be portable.</b> | 615 | Note: <b>This is an internal method. Unlikely to be |
616 | portable. Use at your own risk. </b> | ||
636 | </p> | 617 | </p> |
637 | 618 | ||
638 | <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 619 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
639 | 620 | ||
640 | <p class=name id="getfd"> | 621 | <p class=name id="socket.tcp"> |
641 | master:<b>getfd()</b><br> | 622 | socket.<b>tcp()</b> |
642 | client:<b>getfd()</b><br> | ||
643 | server:<b>getfd()</b> | ||
644 | </p> | 623 | </p> |
645 | 624 | ||
646 | <p class=description> | 625 | <p class=description> |
647 | Returns the underling socket descriptor or handle associated to the object. | 626 | Creates and returns an TCP master object. A master object can |
648 | </p> | 627 | be transformed into a server object with the method |
628 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
629 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
630 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
631 | method supported by a master object is the | ||
632 | <a href=#close><tt>close</tt></a> method.</p> | ||
649 | 633 | ||
650 | <p class=return> | 634 | <p class=return> |
651 | The descriptor or handle. In case the object has been closed, the return will be -1. | 635 | In case of success, a new master object is returned. In case of error, |
636 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
637 | </p> | ||
638 | |||
639 | <p class=note> | ||
640 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
641 | <a href=#bind><tt>bind</tt></a> or <a | ||
642 | href=#bind><tt>connect</tt></a>, depending on the address | ||
643 | family obtained from the resolver. | ||
652 | </p> | 644 | </p> |
653 | 645 | ||
654 | <p class=note> | 646 | <p class=note> |
655 | Note: <b>This is an internal method, any use is unlikely to be portable.</b> | 647 | Note: Before the choice between IPv4 and IPv6 happens, |
648 | the internal socket object is invalid and therefore <a | ||
649 | href=#setoption><tt>setoption</tt></a> will fail. | ||
656 | </p> | 650 | </p> |
657 | 651 | ||
658 | <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 652 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
659 | 653 | ||
660 | <p class=name id="setfd"> | 654 | <p class=name id="socket.tcp4"> |
661 | master:<b>setfd(</b>fd<b>)</b><br> | 655 | socket.<b>tcp4()</b> |
662 | client:<b>setfd(</b>fd<b>)</b><br> | ||
663 | server:<b>setfd(</b>fd<b>)</b> | ||
664 | </p> | 656 | </p> |
665 | 657 | ||
666 | <p class=description> | 658 | <p class=description> |
667 | Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made. | 659 | Creates and returns an IPv4 TCP master object. A master object can |
660 | be transformed into a server object with the method | ||
661 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
662 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
663 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
664 | method supported by a master object is the | ||
665 | <a href=#close><tt>close</tt></a> method.</p> | ||
666 | |||
667 | <p class=return> | ||
668 | In case of success, a new master object is returned. In case of error, | ||
669 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
670 | </p> | ||
671 | |||
672 | <!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
673 | |||
674 | <p class=name id="socket.tcp6"> | ||
675 | socket.<b>tcp6()</b> | ||
668 | </p> | 676 | </p> |
669 | 677 | ||
678 | <p class=description> | ||
679 | Creates and returns an IPv6 TCP master object. A master object can | ||
680 | be transformed into a server object with the method | ||
681 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
682 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
683 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
684 | method supported by a master object is the | ||
685 | <a href=#close><tt>close</tt></a> method.</p> | ||
686 | |||
670 | <p class=return> | 687 | <p class=return> |
671 | No return value. | 688 | In case of success, a new master object is returned. In case of error, |
689 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
672 | </p> | 690 | </p> |
673 | 691 | ||
674 | <p class=note> | 692 | <p class=note> |
675 | Note: <b>This is an internal method, any use is unlikely to be portable.</b> | 693 | Note: The TCP object returned will have the option |
694 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. | ||
676 | </p> | 695 | </p> |
677 | 696 | ||
697 | |||
698 | |||
678 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 699 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
679 | 700 | ||
680 | <div class=footer> | 701 | <div class=footer> |
diff --git a/doc/udp.html b/doc/udp.html index 9437c51..4618aad 100644 --- a/doc/udp.html +++ b/doc/udp.html | |||
@@ -39,112 +39,6 @@ | |||
39 | 39 | ||
40 | <h2 id="udp">UDP</h2> | 40 | <h2 id="udp">UDP</h2> |
41 | 41 | ||
42 | <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
43 | |||
44 | <p class="name" id="socket.udp"> | ||
45 | socket.<b>udp()</b> | ||
46 | </p> | ||
47 | |||
48 | <p class="description"> | ||
49 | Creates and returns an unconnected UDP object. | ||
50 | Unconnected objects support the | ||
51 | <a href="#sendto"><tt>sendto</tt></a>, | ||
52 | <a href="#receive"><tt>receive</tt></a>, | ||
53 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
54 | <a href="#getoption"><tt>getoption</tt></a>, | ||
55 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
56 | <a href="#setoption"><tt>setoption</tt></a>, | ||
57 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
58 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
59 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
60 | <a href="#close"><tt>close</tt></a>. | ||
61 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
62 | is used to connect the object. | ||
63 | </p> | ||
64 | |||
65 | <p class="return"> | ||
66 | In case of success, a new unconnected UDP object | ||
67 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
68 | an error message. | ||
69 | </p> | ||
70 | |||
71 | <p class=note> | ||
72 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
73 | <a href=#sendto><tt>sendto</tt></a>, <a | ||
74 | href=#setpeername><tt>setpeername</tt></a>, or <a | ||
75 | href=#setsockname><tt>sockname</tt></a>, depending on the address | ||
76 | family obtained from the resolver. | ||
77 | </p> | ||
78 | |||
79 | <p class=note> | ||
80 | Note: Before the choice between IPv4 and IPv6 happens, | ||
81 | the internal socket object is invalid and therefore <a | ||
82 | href=#setoption><tt>setoption</tt></a> will fail. | ||
83 | </p> | ||
84 | |||
85 | <!-- socket.udp4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
86 | |||
87 | <p class="name" id="socket.udp"> | ||
88 | socket.<b>udp4()</b> | ||
89 | </p> | ||
90 | |||
91 | <p class="description"> | ||
92 | Creates and returns an unconnected IPv4 UDP object. | ||
93 | Unconnected objects support the | ||
94 | <a href="#sendto"><tt>sendto</tt></a>, | ||
95 | <a href="#receive"><tt>receive</tt></a>, | ||
96 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
97 | <a href="#getoption"><tt>getoption</tt></a>, | ||
98 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
99 | <a href="#setoption"><tt>setoption</tt></a>, | ||
100 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
101 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
102 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
103 | <a href="#close"><tt>close</tt></a>. | ||
104 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
105 | is used to connect the object. | ||
106 | </p> | ||
107 | |||
108 | <p class="return"> | ||
109 | In case of success, a new unconnected UDP object | ||
110 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
111 | an error message. | ||
112 | </p> | ||
113 | |||
114 | <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
115 | |||
116 | <p class="name" id="socket.udp6"> | ||
117 | socket.<b>udp6()</b> | ||
118 | </p> | ||
119 | |||
120 | <p class="description"> | ||
121 | Creates and returns an unconnected IPv6 UDP object. | ||
122 | Unconnected objects support the | ||
123 | <a href="#sendto"><tt>sendto</tt></a>, | ||
124 | <a href="#receive"><tt>receive</tt></a>, | ||
125 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
126 | <a href="#getoption"><tt>getoption</tt></a>, | ||
127 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
128 | <a href="#setoption"><tt>setoption</tt></a>, | ||
129 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
130 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
131 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
132 | <a href="#close"><tt>close</tt></a>. | ||
133 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
134 | is used to connect the object. | ||
135 | </p> | ||
136 | |||
137 | <p class="return"> | ||
138 | In case of success, a new unconnected UDP object | ||
139 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
140 | an error message. | ||
141 | </p> | ||
142 | |||
143 | <p class=note> | ||
144 | Note: The TCP object returned will have the option | ||
145 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. | ||
146 | </p> | ||
147 | |||
148 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 42 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
149 | 43 | ||
150 | <p class="name" id="close"> | 44 | <p class="name" id="close"> |
@@ -168,6 +62,40 @@ Garbage-collected objects are automatically closed before | |||
168 | destruction, though. | 62 | destruction, though. |
169 | </p> | 63 | </p> |
170 | 64 | ||
65 | <!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
66 | |||
67 | <p class="name" id="getoption"> | ||
68 | connected:<b>getoption()</b><br> | ||
69 | unconnected:<b>getoption()</b> | ||
70 | </p> | ||
71 | |||
72 | <p class="description"> | ||
73 | Gets an option value from the UDP object. | ||
74 | See <a href=#setoption><tt>setoption</tt></a> for | ||
75 | description of the option names and values. | ||
76 | </p> | ||
77 | |||
78 | <p class="parameters"><tt>Option</tt> is a string with the option name. | ||
79 | <ul> | ||
80 | <li> '<tt>dontroute</tt>' | ||
81 | <li> '<tt>broadcast</tt>' | ||
82 | <li> '<tt>reuseaddr</tt>' | ||
83 | <li> '<tt>reuseport</tt>' | ||
84 | <li> '<tt>ip-multicast-loop</tt>' | ||
85 | <li> '<tt>ipv6-v6only</tt>' | ||
86 | <li> '<tt>ip-multicast-if</tt>' | ||
87 | <li> '<tt>ip-multicast-ttl</tt>' | ||
88 | <li> '<tt>ip-add-membership</tt>' | ||
89 | <li> '<tt>ip-drop-membership</tt>' | ||
90 | </ul> | ||
91 | </p> | ||
92 | |||
93 | <p class=return> | ||
94 | The method returns the option <tt>value</tt> in case of | ||
95 | success, or | ||
96 | <b><tt>nil</tt></b> followed by an error message otherwise. | ||
97 | </p> | ||
98 | |||
171 | <!-- getpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 99 | <!-- getpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
172 | 100 | ||
173 | <p class="name" id="getpeername"> | 101 | <p class="name" id="getpeername"> |
@@ -218,6 +146,18 @@ first time (in which case it is bound to an ephemeral port and the | |||
218 | wild-card address). | 146 | wild-card address). |
219 | </p> | 147 | </p> |
220 | 148 | ||
149 | <!-- gettimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
150 | |||
151 | <p class=name id="gettimeout"> | ||
152 | connected:<b>settimeout(</b>value<b>)</b><br> | ||
153 | unconnected:<b>settimeout(</b>value<b>)</b> | ||
154 | </p> | ||
155 | |||
156 | <p class=description> | ||
157 | Returns the current timeout value. | ||
158 | </p> | ||
159 | |||
160 | |||
221 | <!-- receive +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 161 | <!-- receive +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
222 | 162 | ||
223 | <p class="name" id="receive"> | 163 | <p class="name" id="receive"> |
@@ -265,40 +205,6 @@ address and port as extra return values (and is therefore slightly less | |||
265 | efficient). | 205 | efficient). |
266 | </p> | 206 | </p> |
267 | 207 | ||
268 | <!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
269 | |||
270 | <p class="name" id="getoption"> | ||
271 | connected:<b>getoption()</b><br> | ||
272 | unconnected:<b>getoption()</b> | ||
273 | </p> | ||
274 | |||
275 | <p class="description"> | ||
276 | Gets an option value from the UDP object. | ||
277 | See <a href=#setoption><tt>setoption</tt></a> for | ||
278 | description of the option names and values. | ||
279 | </p> | ||
280 | |||
281 | <p class="parameters"><tt>Option</tt> is a string with the option name. | ||
282 | <ul> | ||
283 | <li> '<tt>dontroute</tt>' | ||
284 | <li> '<tt>broadcast</tt>' | ||
285 | <li> '<tt>reuseaddr</tt>' | ||
286 | <li> '<tt>reuseport</tt>' | ||
287 | <li> '<tt>ip-multicast-loop</tt>' | ||
288 | <li> '<tt>ipv6-v6only</tt>' | ||
289 | <li> '<tt>ip-multicast-if</tt>' | ||
290 | <li> '<tt>ip-multicast-ttl</tt>' | ||
291 | <li> '<tt>ip-add-membership</tt>' | ||
292 | <li> '<tt>ip-drop-membership</tt>' | ||
293 | </ul> | ||
294 | </p> | ||
295 | |||
296 | <p class=return> | ||
297 | The method returns the option <tt>value</tt> in case of | ||
298 | success, or | ||
299 | <b><tt>nil</tt></b> followed by an error message otherwise. | ||
300 | </p> | ||
301 | |||
302 | <!-- send ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 208 | <!-- send ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
303 | 209 | ||
304 | <p class="name" id="send"> | 210 | <p class="name" id="send"> |
@@ -362,6 +268,75 @@ refuses to send a message to the specified address (i.e. no | |||
362 | interface accepts the address). | 268 | interface accepts the address). |
363 | </p> | 269 | </p> |
364 | 270 | ||
271 | <!-- setoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
272 | |||
273 | <p class="name" id="setoption"> | ||
274 | connected:<b>setoption(</b>option [, value]<b>)</b><br> | ||
275 | unconnected:<b>setoption(</b>option [, value]<b>)</b> | ||
276 | </p> | ||
277 | |||
278 | <p class="description"> | ||
279 | Sets options for the UDP object. Options are | ||
280 | only needed by low-level or time-critical applications. You should | ||
281 | only modify an option if you are sure you need it.</p> | ||
282 | <p class="parameters"><tt>Option</tt> is a string with the option | ||
283 | name, and <tt>value</tt> depends on the option being set: | ||
284 | </p> | ||
285 | |||
286 | <ul> | ||
287 | <li> '<tt>dontroute</tt>': Indicates that outgoing | ||
288 | messages should bypass the standard routing facilities. | ||
289 | Receives a boolean value; | ||
290 | <li> '<tt>broadcast</tt>': Requests permission to send | ||
291 | broadcast datagrams on the socket. | ||
292 | Receives a boolean value; | ||
293 | <li> '<tt>reuseaddr</tt>': Indicates that the rules used in | ||
294 | validating addresses supplied in a <tt>bind()</tt> call | ||
295 | should allow reuse of local addresses. | ||
296 | Receives a boolean value; | ||
297 | <li> '<tt>reuseport</tt>': Allows completely duplicate | ||
298 | bindings by multiple processes if they all set | ||
299 | '<tt>reuseport</tt>' before binding the port. | ||
300 | Receives a boolean value; | ||
301 | <li> '<tt>ip-multicast-loop</tt>': | ||
302 | Specifies whether or not a copy of an outgoing multicast | ||
303 | datagram is delivered to the sending host as long as it is a | ||
304 | member of the multicast group. | ||
305 | Receives a boolean value; | ||
306 | <li> '<tt>ipv6-v6only</tt>': | ||
307 | Specifies whether to restrict <tt>inet6</tt> sockets to | ||
308 | sending and receiving only IPv6 packets. | ||
309 | Receive a boolean value; | ||
310 | <li> '<tt>ip-multicast-if</tt>': | ||
311 | Sets the interface over which outgoing multicast datagrams | ||
312 | are sent. | ||
313 | Receives an IP address; | ||
314 | <li> '<tt>ip-multicast-ttl</tt>': | ||
315 | Sets the Time To Live in the IP header for outgoing | ||
316 | multicast datagrams. | ||
317 | Receives a number; | ||
318 | <li> '<tt>ip-add-membership</tt>': | ||
319 | Joins the multicast group specified. | ||
320 | Receives a table with fields | ||
321 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | ||
322 | IP address; | ||
323 | <li> '<tt>ip-drop-membership</tt>': Leaves the multicast | ||
324 | group specified. | ||
325 | Receives a table with fields | ||
326 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | ||
327 | IP address. | ||
328 | </ul> | ||
329 | |||
330 | <p class="return"> | ||
331 | The method returns 1 in case of success, or | ||
332 | <b><tt>nil</tt></b> followed by an error message otherwise. | ||
333 | </p> | ||
334 | |||
335 | <p class=note> | ||
336 | Note: The descriptions above come from the man pages. | ||
337 | </p> | ||
338 | |||
339 | |||
365 | <!-- setpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 340 | <!-- setpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
366 | 341 | ||
367 | <p class="name" id="setpeername"> | 342 | <p class="name" id="setpeername"> |
@@ -448,74 +423,6 @@ system or explicitly by <tt>setsockname</tt>, it cannot be | |||
448 | changed. | 423 | changed. |
449 | </p> | 424 | </p> |
450 | 425 | ||
451 | <!-- setoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
452 | |||
453 | <p class="name" id="setoption"> | ||
454 | connected:<b>setoption(</b>option [, value]<b>)</b><br> | ||
455 | unconnected:<b>setoption(</b>option [, value]<b>)</b> | ||
456 | </p> | ||
457 | |||
458 | <p class="description"> | ||
459 | Sets options for the UDP object. Options are | ||
460 | only needed by low-level or time-critical applications. You should | ||
461 | only modify an option if you are sure you need it.</p> | ||
462 | <p class="parameters"><tt>Option</tt> is a string with the option | ||
463 | name, and <tt>value</tt> depends on the option being set: | ||
464 | </p> | ||
465 | |||
466 | <ul> | ||
467 | <li> '<tt>dontroute</tt>': Indicates that outgoing | ||
468 | messages should bypass the standard routing facilities. | ||
469 | Receives a boolean value; | ||
470 | <li> '<tt>broadcast</tt>': Requests permission to send | ||
471 | broadcast datagrams on the socket. | ||
472 | Receives a boolean value; | ||
473 | <li> '<tt>reuseaddr</tt>': Indicates that the rules used in | ||
474 | validating addresses supplied in a <tt>bind()</tt> call | ||
475 | should allow reuse of local addresses. | ||
476 | Receives a boolean value; | ||
477 | <li> '<tt>reuseport</tt>': Allows completely duplicate | ||
478 | bindings by multiple processes if they all set | ||
479 | '<tt>reuseport</tt>' before binding the port. | ||
480 | Receives a boolean value; | ||
481 | <li> '<tt>ip-multicast-loop</tt>': | ||
482 | Specifies whether or not a copy of an outgoing multicast | ||
483 | datagram is delivered to the sending host as long as it is a | ||
484 | member of the multicast group. | ||
485 | Receives a boolean value; | ||
486 | <li> '<tt>ipv6-v6only</tt>': | ||
487 | Specifies whether to restrict <tt>inet6</tt> sockets to | ||
488 | sending and receiving only IPv6 packets. | ||
489 | Receive a boolean value; | ||
490 | <li> '<tt>ip-multicast-if</tt>': | ||
491 | Sets the interface over which outgoing multicast datagrams | ||
492 | are sent. | ||
493 | Receives an IP address; | ||
494 | <li> '<tt>ip-multicast-ttl</tt>': | ||
495 | Sets the Time To Live in the IP header for outgoing | ||
496 | multicast datagrams. | ||
497 | Receives a number; | ||
498 | <li> '<tt>ip-add-membership</tt>': | ||
499 | Joins the multicast group specified. | ||
500 | Receives a table with fields | ||
501 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | ||
502 | IP address; | ||
503 | <li> '<tt>ip-drop-membership</tt>': Leaves the multicast | ||
504 | group specified. | ||
505 | Receives a table with fields | ||
506 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | ||
507 | IP address. | ||
508 | </ul> | ||
509 | |||
510 | <p class="return"> | ||
511 | The method returns 1 in case of success, or | ||
512 | <b><tt>nil</tt></b> followed by an error message otherwise. | ||
513 | </p> | ||
514 | |||
515 | <p class=note> | ||
516 | Note: The descriptions above come from the man pages. | ||
517 | </p> | ||
518 | |||
519 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 426 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
520 | 427 | ||
521 | <p class="name" id="settimeout"> | 428 | <p class="name" id="settimeout"> |
@@ -556,6 +463,114 @@ all other method names already contained verbs making their | |||
556 | imperative nature obvious. | 463 | imperative nature obvious. |
557 | </p> | 464 | </p> |
558 | 465 | ||
466 | <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
467 | |||
468 | <p class="name" id="socket.udp"> | ||
469 | socket.<b>udp()</b> | ||
470 | </p> | ||
471 | |||
472 | <p class="description"> | ||
473 | Creates and returns an unconnected UDP object. | ||
474 | Unconnected objects support the | ||
475 | <a href="#sendto"><tt>sendto</tt></a>, | ||
476 | <a href="#receive"><tt>receive</tt></a>, | ||
477 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
478 | <a href="#getoption"><tt>getoption</tt></a>, | ||
479 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
480 | <a href="#setoption"><tt>setoption</tt></a>, | ||
481 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
482 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
483 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
484 | <a href="#close"><tt>close</tt></a>. | ||
485 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
486 | is used to connect the object. | ||
487 | </p> | ||
488 | |||
489 | <p class="return"> | ||
490 | In case of success, a new unconnected UDP object | ||
491 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
492 | an error message. | ||
493 | </p> | ||
494 | |||
495 | <p class=note> | ||
496 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
497 | <a href=#sendto><tt>sendto</tt></a>, <a | ||
498 | href=#setpeername><tt>setpeername</tt></a>, or <a | ||
499 | href=#setsockname><tt>sockname</tt></a>, depending on the address | ||
500 | family obtained from the resolver. | ||
501 | </p> | ||
502 | |||
503 | <p class=note> | ||
504 | Note: Before the choice between IPv4 and IPv6 happens, | ||
505 | the internal socket object is invalid and therefore <a | ||
506 | href=#setoption><tt>setoption</tt></a> will fail. | ||
507 | </p> | ||
508 | |||
509 | <!-- socket.udp4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
510 | |||
511 | <p class="name" id="socket.udp"> | ||
512 | socket.<b>udp4()</b> | ||
513 | </p> | ||
514 | |||
515 | <p class="description"> | ||
516 | Creates and returns an unconnected IPv4 UDP object. | ||
517 | Unconnected objects support the | ||
518 | <a href="#sendto"><tt>sendto</tt></a>, | ||
519 | <a href="#receive"><tt>receive</tt></a>, | ||
520 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
521 | <a href="#getoption"><tt>getoption</tt></a>, | ||
522 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
523 | <a href="#setoption"><tt>setoption</tt></a>, | ||
524 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
525 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
526 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
527 | <a href="#close"><tt>close</tt></a>. | ||
528 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
529 | is used to connect the object. | ||
530 | </p> | ||
531 | |||
532 | <p class="return"> | ||
533 | In case of success, a new unconnected UDP object | ||
534 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
535 | an error message. | ||
536 | </p> | ||
537 | |||
538 | <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
539 | |||
540 | <p class="name" id="socket.udp6"> | ||
541 | socket.<b>udp6()</b> | ||
542 | </p> | ||
543 | |||
544 | <p class="description"> | ||
545 | Creates and returns an unconnected IPv6 UDP object. | ||
546 | Unconnected objects support the | ||
547 | <a href="#sendto"><tt>sendto</tt></a>, | ||
548 | <a href="#receive"><tt>receive</tt></a>, | ||
549 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
550 | <a href="#getoption"><tt>getoption</tt></a>, | ||
551 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
552 | <a href="#setoption"><tt>setoption</tt></a>, | ||
553 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
554 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
555 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
556 | <a href="#close"><tt>close</tt></a>. | ||
557 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
558 | is used to connect the object. | ||
559 | </p> | ||
560 | |||
561 | <p class="return"> | ||
562 | In case of success, a new unconnected UDP object | ||
563 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
564 | an error message. | ||
565 | </p> | ||
566 | |||
567 | <p class=note> | ||
568 | Note: The TCP object returned will have the option | ||
569 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. | ||
570 | </p> | ||
571 | |||
572 | |||
573 | |||
559 | <!-- footer ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 574 | <!-- footer ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
560 | 575 | ||
561 | <div class=footer> | 576 | <div class=footer> |
@@ -36,6 +36,7 @@ static int meth_accept(lua_State *L); | |||
36 | static int meth_close(lua_State *L); | 36 | static int meth_close(lua_State *L); |
37 | static int meth_getoption(lua_State *L); | 37 | static int meth_getoption(lua_State *L); |
38 | static int meth_setoption(lua_State *L); | 38 | static int meth_setoption(lua_State *L); |
39 | static int meth_gettimeout(lua_State *L); | ||
39 | static int meth_settimeout(lua_State *L); | 40 | static int meth_settimeout(lua_State *L); |
40 | static int meth_getfd(lua_State *L); | 41 | static int meth_getfd(lua_State *L); |
41 | static int meth_setfd(lua_State *L); | 42 | static int meth_setfd(lua_State *L); |
@@ -65,6 +66,7 @@ static luaL_Reg tcp_methods[] = { | |||
65 | {"setpeername", meth_connect}, | 66 | {"setpeername", meth_connect}, |
66 | {"setsockname", meth_bind}, | 67 | {"setsockname", meth_bind}, |
67 | {"settimeout", meth_settimeout}, | 68 | {"settimeout", meth_settimeout}, |
69 | {"gettimeout", meth_gettimeout}, | ||
68 | {"shutdown", meth_shutdown}, | 70 | {"shutdown", meth_shutdown}, |
69 | {NULL, NULL} | 71 | {NULL, NULL} |
70 | }; | 72 | }; |
@@ -350,6 +352,12 @@ static int meth_settimeout(lua_State *L) | |||
350 | return timeout_meth_settimeout(L, &tcp->tm); | 352 | return timeout_meth_settimeout(L, &tcp->tm); |
351 | } | 353 | } |
352 | 354 | ||
355 | static int meth_gettimeout(lua_State *L) | ||
356 | { | ||
357 | p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); | ||
358 | return timeout_meth_gettimeout(L, &tcp->tm); | ||
359 | } | ||
360 | |||
353 | /*=========================================================================*\ | 361 | /*=========================================================================*\ |
354 | * Library functions | 362 | * Library functions |
355 | \*=========================================================================*/ | 363 | \*=========================================================================*/ |
diff --git a/src/timeout.c b/src/timeout.c index 087d033..5a601d5 100644 --- a/src/timeout.c +++ b/src/timeout.c | |||
@@ -173,6 +173,16 @@ int timeout_meth_settimeout(lua_State *L, p_timeout tm) { | |||
173 | return 1; | 173 | return 1; |
174 | } | 174 | } |
175 | 175 | ||
176 | /*-------------------------------------------------------------------------*\ | ||
177 | * Gets timeout values for IO operations | ||
178 | * Lua Output: block, total | ||
179 | \*-------------------------------------------------------------------------*/ | ||
180 | int timeout_meth_gettimeout(lua_State *L, p_timeout tm) { | ||
181 | lua_pushnumber(L, tm->block); | ||
182 | lua_pushnumber(L, tm->total); | ||
183 | return 2; | ||
184 | } | ||
185 | |||
176 | /*=========================================================================*\ | 186 | /*=========================================================================*\ |
177 | * Test support functions | 187 | * Test support functions |
178 | \*=========================================================================*/ | 188 | \*=========================================================================*/ |
diff --git a/src/timeout.h b/src/timeout.h index 6715ca7..af90231 100644 --- a/src/timeout.h +++ b/src/timeout.h | |||
@@ -22,6 +22,7 @@ p_timeout timeout_markstart(p_timeout tm); | |||
22 | double timeout_getstart(p_timeout tm); | 22 | double timeout_getstart(p_timeout tm); |
23 | double timeout_gettime(void); | 23 | double timeout_gettime(void); |
24 | int timeout_meth_settimeout(lua_State *L, p_timeout tm); | 24 | int timeout_meth_settimeout(lua_State *L, p_timeout tm); |
25 | int timeout_meth_gettimeout(lua_State *L, p_timeout tm); | ||
25 | 26 | ||
26 | #define timeout_iszero(tm) ((tm)->block == 0.0) | 27 | #define timeout_iszero(tm) ((tm)->block == 0.0) |
27 | 28 | ||
@@ -36,6 +36,7 @@ static int meth_receivefrom(lua_State *L); | |||
36 | static int meth_getfamily(lua_State *L); | 36 | static int meth_getfamily(lua_State *L); |
37 | static int meth_getsockname(lua_State *L); | 37 | static int meth_getsockname(lua_State *L); |
38 | static int meth_getpeername(lua_State *L); | 38 | static int meth_getpeername(lua_State *L); |
39 | static int meth_gettimeout(lua_State *L); | ||
39 | static int meth_setsockname(lua_State *L); | 40 | static int meth_setsockname(lua_State *L); |
40 | static int meth_setpeername(lua_State *L); | 41 | static int meth_setpeername(lua_State *L); |
41 | static int meth_close(lua_State *L); | 42 | static int meth_close(lua_State *L); |
@@ -66,6 +67,7 @@ static luaL_Reg udp_methods[] = { | |||
66 | {"setpeername", meth_setpeername}, | 67 | {"setpeername", meth_setpeername}, |
67 | {"setsockname", meth_setsockname}, | 68 | {"setsockname", meth_setsockname}, |
68 | {"settimeout", meth_settimeout}, | 69 | {"settimeout", meth_settimeout}, |
70 | {"gettimeout", meth_gettimeout}, | ||
69 | {NULL, NULL} | 71 | {NULL, NULL} |
70 | }; | 72 | }; |
71 | 73 | ||
@@ -347,6 +349,11 @@ static int meth_settimeout(lua_State *L) { | |||
347 | return timeout_meth_settimeout(L, &udp->tm); | 349 | return timeout_meth_settimeout(L, &udp->tm); |
348 | } | 350 | } |
349 | 351 | ||
352 | static int meth_gettimeout(lua_State *L) { | ||
353 | p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); | ||
354 | return timeout_meth_gettimeout(L, &udp->tm); | ||
355 | } | ||
356 | |||
350 | /*-------------------------------------------------------------------------*\ | 357 | /*-------------------------------------------------------------------------*\ |
351 | * Turns a master udp object into a client object. | 358 | * Turns a master udp object into a client object. |
352 | \*-------------------------------------------------------------------------*/ | 359 | \*-------------------------------------------------------------------------*/ |