diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-16 20:41:03 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-16 20:41:03 +0000 |
| commit | ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc (patch) | |
| tree | 1a49ac4a3c74b9d3bf8e4220d4bf9c48641f3dbc | |
| parent | 0a4c1534f39511894728da193ab8225ad6022de9 (diff) | |
| download | luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.tar.gz luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.tar.bz2 luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.zip | |
Fine tuning the manual...
| -rw-r--r-- | doc/ftp.html | 23 | ||||
| -rw-r--r-- | doc/http.html | 28 | ||||
| -rw-r--r-- | doc/index.html | 18 | ||||
| -rw-r--r-- | doc/introduction.html | 2 | ||||
| -rw-r--r-- | doc/ltn12.html | 3 | ||||
| -rw-r--r-- | doc/mime.html | 19 | ||||
| -rw-r--r-- | doc/smtp.html | 77 | ||||
| -rw-r--r-- | doc/socket.html | 42 |
8 files changed, 129 insertions, 83 deletions
diff --git a/doc/ftp.html b/doc/ftp.html index 9fda02b..7ad5e4d 100644 --- a/doc/ftp.html +++ b/doc/ftp.html | |||
| @@ -54,7 +54,8 @@ To really benefit from this module, a good understanding of | |||
| 54 | LTN012, Filters sources and sinks</a> is necessary. | 54 | LTN012, Filters sources and sinks</a> is necessary. |
| 55 | </p> | 55 | </p> |
| 56 | 56 | ||
| 57 | <p class=description> To obtain the <tt>ftp</tt> namespace, run: | 57 | <p> |
| 58 | To obtain the <tt>ftp</tt> namespace, run: | ||
| 58 | </p> | 59 | </p> |
| 59 | 60 | ||
| 60 | <pre class=example> | 61 | <pre class=example> |
| @@ -99,7 +100,7 @@ ftp.<b>get{</b><br> | |||
| 99 | [command = <i>string</i>,]<br> | 100 | [command = <i>string</i>,]<br> |
| 100 | [port = <i>number</i>,]<br> | 101 | [port = <i>number</i>,]<br> |
| 101 | [type = <i>string</i>,]<br> | 102 | [type = <i>string</i>,]<br> |
| 102 | [step = <i>LTN12 pump step</i>],<br> | 103 | [step = <i>LTN12 pump step</i>,]<br> |
| 103 | <b>}</b> | 104 | <b>}</b> |
| 104 | </p> | 105 | </p> |
| 105 | 106 | ||
| @@ -115,7 +116,9 @@ If the argument of the <tt>get</tt> function is a table, the function | |||
| 115 | expects at least the fields <tt>host</tt>, <tt>sink</tt>, and one of | 116 | expects at least the fields <tt>host</tt>, <tt>sink</tt>, and one of |
| 116 | <tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes | 117 | <tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes |
| 117 | precedence). <tt>Host</tt> is the server to connect to. <tt>Sink</tt> is | 118 | precedence). <tt>Host</tt> is the server to connect to. <tt>Sink</tt> is |
| 118 | the <em>simple</em> LTN12 sink that will receive the downloaded data. <tt>Argument</tt> or | 119 | the <em>simple</em> |
| 120 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 121 | sink that will receive the downloaded data. <tt>Argument</tt> or | ||
| 119 | <tt>path</tt> give the target path to the resource in the server. The | 122 | <tt>path</tt> give the target path to the resource in the server. The |
| 120 | optional arguments are the following: | 123 | optional arguments are the following: |
| 121 | </p> | 124 | </p> |
| @@ -127,7 +130,9 @@ authentication. Defaults to "<tt>ftp:anonymous@anonymous.org</tt>"; | |||
| 127 | <li><tt>port</tt>: The port to used for the control connection. Defaults to 21; | 130 | <li><tt>port</tt>: The port to used for the control connection. Defaults to 21; |
| 128 | <li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or | 131 | <li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or |
| 129 | "<tt>a</tt>". Defaults to whatever is the server default; | 132 | "<tt>a</tt>". Defaults to whatever is the server default; |
| 130 | <li><tt>step</tt>: LTN12 pump step function used to pass data from the | 133 | <li><tt>step</tt>: |
| 134 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 135 | pump step function used to pass data from the | ||
| 131 | server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function. | 136 | server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function. |
| 132 | </ul> | 137 | </ul> |
| 133 | 138 | ||
| @@ -177,7 +182,7 @@ ftp.<b>put{</b><br> | |||
| 177 | [command = <i>string</i>,]<br> | 182 | [command = <i>string</i>,]<br> |
| 178 | [port = <i>number</i>,]<br> | 183 | [port = <i>number</i>,]<br> |
| 179 | [type = <i>string</i>,]<br> | 184 | [type = <i>string</i>,]<br> |
| 180 | [step = <i>LTN12 pump step</i>],<br> | 185 | [step = <i>LTN12 pump step</i>,]<br> |
| 181 | <b>}</b> | 186 | <b>}</b> |
| 182 | </p> | 187 | </p> |
| 183 | 188 | ||
| @@ -192,7 +197,9 @@ If the argument of the <tt>put</tt> function is a table, the function | |||
| 192 | expects at least the fields <tt>host</tt>, <tt>source</tt>, and one of | 197 | expects at least the fields <tt>host</tt>, <tt>source</tt>, and one of |
| 193 | <tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes | 198 | <tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes |
| 194 | precedence). <tt>Host</tt> is the server to connect to. <tt>Source</tt> is | 199 | precedence). <tt>Host</tt> is the server to connect to. <tt>Source</tt> is |
| 195 | the <em>simple</em> LTN12 source that will provide the contents to be uploaded. | 200 | the <em>simple</em> |
| 201 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 202 | source that will provide the contents to be uploaded. | ||
| 196 | <tt>Argument</tt> or | 203 | <tt>Argument</tt> or |
| 197 | <tt>path</tt> give the target path to the resource in the server. The | 204 | <tt>path</tt> give the target path to the resource in the server. The |
| 198 | optional arguments are the following: | 205 | optional arguments are the following: |
| @@ -205,7 +212,9 @@ authentication. Defaults to "<tt>ftp:anonymous@anonymous.org</tt>"; | |||
| 205 | <li><tt>port</tt>: The port to used for the control connection. Defaults to 21; | 212 | <li><tt>port</tt>: The port to used for the control connection. Defaults to 21; |
| 206 | <li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or | 213 | <li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or |
| 207 | "<tt>a</tt>". Defaults to whatever is the server default; | 214 | "<tt>a</tt>". Defaults to whatever is the server default; |
| 208 | <li><tt>step</tt>: LTN12 pump step function used to pass data from the | 215 | <li><tt>step</tt>: |
| 216 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 217 | pump step function used to pass data from the | ||
| 209 | server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function. | 218 | server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function. |
| 210 | </ul> | 219 | </ul> |
| 211 | 220 | ||
diff --git a/doc/http.html b/doc/http.html index 0fc04cd..a621ec7 100644 --- a/doc/http.html +++ b/doc/http.html | |||
| @@ -50,11 +50,13 @@ implementation conforms to the HTTP/1.1 standard, | |||
| 50 | The module exports functions that provide HTTP functionality in different | 50 | The module exports functions that provide HTTP functionality in different |
| 51 | levels of abstraction, from the simple | 51 | levels of abstraction, from the simple |
| 52 | <a href="#get"><tt>get</tt></a> function, through the generic | 52 | <a href="#get"><tt>get</tt></a> function, through the generic |
| 53 | LTN12 based <a href="#request"><tt>request</tt></a> function, down to | 53 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> based |
| 54 | <a href="#request"><tt>request</tt></a> function, down to | ||
| 54 | even lower-level if you bother to look through the source code. | 55 | even lower-level if you bother to look through the source code. |
| 55 | </p> | 56 | </p> |
| 56 | 57 | ||
| 57 | <p class=description> To obtain the <tt>ftp</tt> namespace, run: | 58 | <p> |
| 59 | To obtain the <tt>http</tt> namespace, run: | ||
| 58 | </p> | 60 | </p> |
| 59 | 61 | ||
| 60 | <pre class=example> | 62 | <pre class=example> |
| @@ -85,12 +87,8 @@ MIME headers are represented as a Lua table in the form: | |||
| 85 | headers = {<br> | 87 | headers = {<br> |
| 86 | field-1-name = <i>field-1-value</i>,<br> | 88 | field-1-name = <i>field-1-value</i>,<br> |
| 87 | field-2-name = <i>field-2-value</i>,<br> | 89 | field-2-name = <i>field-2-value</i>,<br> |
| 88 | field-3-name = <i>field-3-value</i>, | 90 | field-3-name = <i>field-3-value</i>,<br> |
| 89 | </tt></td></tr> | 91 | ...<br> |
| 90 | <tr><td align=center><tt> | ||
| 91 | ... | ||
| 92 | </tt></td></tr> | ||
| 93 | <tr><td><tt> | ||
| 94 | field-n-name = <i>field-n-value</i><br> | 92 | field-n-name = <i>field-n-value</i><br> |
| 95 | } | 93 | } |
| 96 | </tt></td></tr> | 94 | </tt></td></tr> |
| @@ -188,7 +186,7 @@ Note: This function is also trivially implemented with the use of the | |||
| 188 | <p class=name id=request> | 186 | <p class=name id=request> |
| 189 | http.<b>request{</b><br> | 187 | http.<b>request{</b><br> |
| 190 | url = <i>string</i>,<br> | 188 | url = <i>string</i>,<br> |
| 191 | [sink = <i>LTN12 sink</i>],]<br> | 189 | [sink = <i>LTN12 sink</i>,]<br> |
| 192 | [method = <i>string</i>,]<br> | 190 | [method = <i>string</i>,]<br> |
| 193 | [headers = <i>header-table</i>,]<br> | 191 | [headers = <i>header-table</i>,]<br> |
| 194 | [source = <i>LTN12 source</i>],<br> | 192 | [source = <i>LTN12 source</i>],<br> |
| @@ -203,7 +201,9 @@ Performs the generic HTTP request, controlled by a request table. | |||
| 203 | </p> | 201 | </p> |
| 204 | 202 | ||
| 205 | <p class=parameters> | 203 | <p class=parameters> |
| 206 | The most important parameters are the <tt>url</tt> and the <em>simple</em> LTN12 <tt>sink</tt> that will receive the downloaded content. | 204 | The most important parameters are the <tt>url</tt> and the <em>simple</em> |
| 205 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 206 | <tt>sink</tt> that will receive the downloaded content. | ||
| 207 | Any part of the <tt>url</tt> can be overridden by including | 207 | Any part of the <tt>url</tt> can be overridden by including |
| 208 | the appropriate field in the request table. | 208 | the appropriate field in the request table. |
| 209 | If authentication information is provided, the function | 209 | If authentication information is provided, the function |
| @@ -215,11 +215,15 @@ following: | |||
| 215 | <ul> | 215 | <ul> |
| 216 | <li><tt>method</tt>: The HTTP request method. Defaults to "GET"; | 216 | <li><tt>method</tt>: The HTTP request method. Defaults to "GET"; |
| 217 | <li><tt>headers</tt>: Any additional HTTP headers to send with the request; | 217 | <li><tt>headers</tt>: Any additional HTTP headers to send with the request; |
| 218 | <li><tt>source</tt>: <em>simple</em> LTN12 source to provide the request body. If there | 218 | <li><tt>source</tt>: <em>simple</em> |
| 219 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 220 | source to provide the request body. If there | ||
| 219 | is a body, you need to provide an appropriate "<tt>content-length</tt>" | 221 | is a body, you need to provide an appropriate "<tt>content-length</tt>" |
| 220 | request header field, or the function will attempt to send the body as | 222 | request header field, or the function will attempt to send the body as |
| 221 | "<tt>chunked</tt>" (something few servers support). Defaults to the empty source; | 223 | "<tt>chunked</tt>" (something few servers support). Defaults to the empty source; |
| 222 | <li><tt>step</tt>: LTN12 pump step function used to move data. | 224 | <li><tt>step</tt>: |
| 225 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 226 | pump step function used to move data. | ||
| 223 | Defaults to the LTN12 <tt>pump.step</tt> function. | 227 | Defaults to the LTN12 <tt>pump.step</tt> function. |
| 224 | <li><tt>proxy</tt>: The URL of a proxy server to use. Defaults to no proxy; | 228 | <li><tt>proxy</tt>: The URL of a proxy server to use. Defaults to no proxy; |
| 225 | <li><tt>redirect</tt>: Set to <tt><b>false</b></tt> to prevent the | 229 | <li><tt>redirect</tt>: Set to <tt><b>false</b></tt> to prevent the |
diff --git a/doc/index.html b/doc/index.html index 888bc92..f6d37ac 100644 --- a/doc/index.html +++ b/doc/index.html | |||
| @@ -51,13 +51,21 @@ and Unix platforms. | |||
| 51 | </p> | 51 | </p> |
| 52 | 52 | ||
| 53 | <p> | 53 | <p> |
| 54 | The most used modules implement the SMTP (sending e-mails), HTTP | 54 | The most used modules implement the |
| 55 | (WWW access) and FTP (uploading and downloading files) client | 55 | <a href=smtp.html>SMTP</a> |
| 56 | (sending e-mails), | ||
| 57 | <a href=http.html>HTTP</a> | ||
| 58 | (WWW access) and | ||
| 59 | <a href=ftp.html>FTP</a> | ||
| 60 | (uploading and downloading files) client | ||
| 56 | protocols. These provide a very natural and generic interface to the e | 61 | protocols. These provide a very natural and generic interface to the e |
| 57 | functionality covered by the protocols. | 62 | functionality covered by the protocols. |
| 58 | In addition, you will find that the MIME (common encodings), URL (anything you | 63 | In addition, you will find that the |
| 59 | could possible want to do with one) and LTN12 (filters, sinks, sources | 64 | <a href=mime.html>MIME</a> (common encodings), |
| 60 | and pumps) modules can be very handy. | 65 | <a href=url.html>URL</a> |
| 66 | (anything you could possible want to do with one) and | ||
| 67 | <a href=ltn12.html>LTN12</a> | ||
| 68 | (filters, sinks, sources and pumps) modules can be very handy. | ||
| 61 | </p> | 69 | </p> |
| 62 | 70 | ||
| 63 | <p> | 71 | <p> |
diff --git a/doc/introduction.html b/doc/introduction.html index 59d1956..63a7d84 100644 --- a/doc/introduction.html +++ b/doc/introduction.html | |||
| @@ -122,7 +122,7 @@ from the "<tt>socket</tt>" namespace. | |||
| 122 | <pre class="example"> | 122 | <pre class="example"> |
| 123 | socket = require("socket") | 123 | socket = require("socket") |
| 124 | print(socket.VERSION) | 124 | print(socket.VERSION) |
| 125 | -- LuaSocket 2.0 | 125 | --> LuaSocket 2.0 |
| 126 | </pre> | 126 | </pre> |
| 127 | 127 | ||
| 128 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 128 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
diff --git a/doc/ltn12.html b/doc/ltn12.html index 7b379c2..9029b9c 100644 --- a/doc/ltn12.html +++ b/doc/ltn12.html | |||
| @@ -42,7 +42,8 @@ functions. Please refer to the LTN for a deeper explanation of the | |||
| 42 | functionality provided by this module. | 42 | functionality provided by this module. |
| 43 | </p> | 43 | </p> |
| 44 | 44 | ||
| 45 | <p class=description> To obtain the <tt>ltn12</tt> namespace, run: | 45 | <p> |
| 46 | To obtain the <tt>ltn12</tt> namespace, run: | ||
| 46 | </p> | 47 | </p> |
| 47 | 48 | ||
| 48 | <pre class=example> | 49 | <pre class=example> |
diff --git a/doc/mime.html b/doc/mime.html index 791861e..e7211fa 100644 --- a/doc/mime.html +++ b/doc/mime.html | |||
| @@ -55,7 +55,8 @@ follows the ideas presented in | |||
| 55 | LTN012, Filters sources and sinks</a>. | 55 | LTN012, Filters sources and sinks</a>. |
| 56 | </p> | 56 | </p> |
| 57 | 57 | ||
| 58 | <p class=description> To obtain the <tt>mime</tt> namespace, run: | 58 | <p> |
| 59 | To obtain the <tt>mime</tt> namespace, run: | ||
| 59 | </p> | 60 | </p> |
| 60 | 61 | ||
| 61 | <pre class=example> | 62 | <pre class=example> |
| @@ -109,10 +110,6 @@ Returns a filter that decodes data from a given transfer content | |||
| 109 | encoding. | 110 | encoding. |
| 110 | </p> | 111 | </p> |
| 111 | 112 | ||
| 112 | <p class=return> | ||
| 113 | The function returns the created filter. | ||
| 114 | </p> | ||
| 115 | |||
| 116 | <!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 113 | <!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 117 | 114 | ||
| 118 | <p class=name id="encode"> | 115 | <p class=name id="encode"> |
| @@ -131,10 +128,6 @@ textual or binary, by passing the <tt>mode</tt> strings "<tt>text</tt>" or | |||
| 131 | "<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>". | 128 | "<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>". |
| 132 | </p> | 129 | </p> |
| 133 | 130 | ||
| 134 | <p class=return> | ||
| 135 | The function returns the created filter. | ||
| 136 | </p> | ||
| 137 | |||
| 138 | <p class=note> | 131 | <p class=note> |
| 139 | Although both transfer content encodings specify a limit for the line | 132 | Although both transfer content encodings specify a limit for the line |
| 140 | length, the encoding filters do <em>not</em> break text into lines (for | 133 | length, the encoding filters do <em>not</em> break text into lines (for |
| @@ -186,10 +179,6 @@ not to break lines in the middle of an escaped character. In that case, the | |||
| 186 | line length is fixed at 76. | 179 | line length is fixed at 76. |
| 187 | </p> | 180 | </p> |
| 188 | 181 | ||
| 189 | <p class=return> | ||
| 190 | The function returns the created filter. | ||
| 191 | </p> | ||
| 192 | |||
| 193 | <p class=note> | 182 | <p class=note> |
| 194 | For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following: | 183 | For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following: |
| 195 | </p> | 184 | </p> |
| @@ -260,9 +249,7 @@ the context is returned after each new chunk. | |||
| 260 | ASCII value of the last character of the previous chunk, if it was a | 249 | ASCII value of the last character of the previous chunk, if it was a |
| 261 | candidate for line break, or 0 otherwise. | 250 | candidate for line break, or 0 otherwise. |
| 262 | <tt>B</tt> is the same as <tt>C</tt>, but for the current | 251 | <tt>B</tt> is the same as <tt>C</tt>, but for the current |
| 263 | chunk. If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> includes a | 252 | chunk. <tt>Marker</tt> gives the new end-of-line marker and defaults to CRLF. |
| 264 | new end-of-line marker, depending on <tt>C</tt>. | ||
| 265 | <tt>Marker</tt> gives the new end-of-line marker and defaults to CRLF. | ||
| 266 | </p> | 253 | </p> |
| 267 | 254 | ||
| 268 | <pre class=example> | 255 | <pre class=example> |
diff --git a/doc/smtp.html b/doc/smtp.html index 0fdc4a4..6b348e0 100644 --- a/doc/smtp.html +++ b/doc/smtp.html | |||
| @@ -35,8 +35,15 @@ | |||
| 35 | 35 | ||
| 36 | <h2 id=smtp>SMTP</h2> | 36 | <h2 id=smtp>SMTP</h2> |
| 37 | 37 | ||
| 38 | <p> The <tt>smtp.lua</tt> module provides functionality to send e-mail | 38 | <p> The <tt>smtp</tt> namespace provides functionality to send e-mail |
| 39 | messages. The implementation conforms to the Simple Mail Transfer Protocol, | 39 | messages. The high-level API consists of two functions: one to |
| 40 | define an e-mail message, and another to actually send the message. | ||
| 41 | Although almost all users will find that these functions provide more than | ||
| 42 | enough functionality, the underlying implementation allows for even more | ||
| 43 | control (if you bother to read the code). | ||
| 44 | </p> | ||
| 45 | |||
| 46 | <p>The implementation conforms to the Simple Mail Transfer Protocol, | ||
| 40 | <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2821.txt">RFC 2821</a>. | 47 | <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2821.txt">RFC 2821</a>. |
| 41 | Another RFC of interest is <a | 48 | Another RFC of interest is <a |
| 42 | href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>, | 49 | href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>, |
| @@ -52,6 +59,15 @@ sources and sinks</a> and the <a href=mime.html>MIME</a> module is | |||
| 52 | assumed. In fact, the SMTP module was the main reason for their | 59 | assumed. In fact, the SMTP module was the main reason for their |
| 53 | creation. </p> | 60 | creation. </p> |
| 54 | 61 | ||
| 62 | <p> | ||
| 63 | To obtain the <tt>smtp</tt> namespace, run: | ||
| 64 | </p> | ||
| 65 | |||
| 66 | <pre class=example> | ||
| 67 | -- loads the SMTP module and everything it requires | ||
| 68 | local smtp = require("smtp") | ||
| 69 | </pre> | ||
| 70 | |||
| 55 | <p> | 71 | <p> |
| 56 | MIME headers are represented as a Lua table in the form: | 72 | MIME headers are represented as a Lua table in the form: |
| 57 | </p> | 73 | </p> |
| @@ -62,12 +78,8 @@ MIME headers are represented as a Lua table in the form: | |||
| 62 | headers = {<br> | 78 | headers = {<br> |
| 63 | field-1-name = <i>field-1-value</i>,<br> | 79 | field-1-name = <i>field-1-value</i>,<br> |
| 64 | field-2-name = <i>field-2-value</i>,<br> | 80 | field-2-name = <i>field-2-value</i>,<br> |
| 65 | field-3-name = <i>field-3-value</i>, | 81 | field-3-name = <i>field-3-value</i>,<br> |
| 66 | </tt></td></tr> | 82 | ...<br> |
| 67 | <tr><td align=center><tt> | ||
| 68 | ... | ||
| 69 | </tt></td></tr> | ||
| 70 | <tr><td><tt> | ||
| 71 | field-n-name = <i>field-n-value</i><br> | 83 | field-n-name = <i>field-n-value</i><br> |
| 72 | } | 84 | } |
| 73 | </tt></td></tr> | 85 | </tt></td></tr> |
| @@ -105,12 +117,12 @@ smtp.<b>send{</b><br> | |||
| 105 | from = <i>string</i>,<br> | 117 | from = <i>string</i>,<br> |
| 106 | rcpt = <i>string</i> or <i>string-table</i>,<br> | 118 | rcpt = <i>string</i> or <i>string-table</i>,<br> |
| 107 | source = <i>LTN12 source</i>,<br> | 119 | source = <i>LTN12 source</i>,<br> |
| 108 | [user = <i>string</i>],<br> | 120 | [user = <i>string</i>,]<br> |
| 109 | [password = <i>string</i>],<br> | 121 | [password = <i>string</i>,]<br> |
| 110 | [server = <i>string</i>],<br> | 122 | [server = <i>string</i>,]<br> |
| 111 | [port = <i>string</i>]<br> | 123 | [port = <i>string</i>,]<br> |
| 112 | [domain = <i>string</i>],<br> | 124 | [domain = <i>string</i>,]<br> |
| 113 | [step = <i>LTN12 pump step</i>],<br> | 125 | [step = <i>LTN12 pump step</i>,]<br> |
| 114 | <b>}</b> | 126 | <b>}</b> |
| 115 | </p> | 127 | </p> |
| 116 | 128 | ||
| @@ -127,8 +139,9 @@ The sender is given by the e-mail address in the <tt>from</tt> field. | |||
| 127 | <tt>Rcpt</tt> is a Lua table with one entry for each recipient e-mail | 139 | <tt>Rcpt</tt> is a Lua table with one entry for each recipient e-mail |
| 128 | address, or a string | 140 | address, or a string |
| 129 | in case there is just one recipient. | 141 | in case there is just one recipient. |
| 130 | The contents of the message are given by a <em>simple</em> LTN12 <tt>source</tt>. Several | 142 | The contents of the message are given by a <em>simple</em> |
| 131 | arguments are optional: | 143 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
| 144 | <tt>source</tt>. Several arguments are optional: | ||
| 132 | </p> | 145 | </p> |
| 133 | <ul> | 146 | <ul> |
| 134 | <li> <tt>user</tt>, <tt>password</tt>: User and password for | 147 | <li> <tt>user</tt>, <tt>password</tt>: User and password for |
| @@ -138,7 +151,9 @@ methods if supported by the server (both are unsafe); | |||
| 138 | <li> <tt>port</tt>: Port to connect to. Defaults to 25; | 151 | <li> <tt>port</tt>: Port to connect to. Defaults to 25; |
| 139 | <li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the | 152 | <li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the |
| 140 | local machine host name; | 153 | local machine host name; |
| 141 | <li> <tt>step</tt>: LTN12 pump step function used to pass data from the | 154 | <li> <tt>step</tt>: |
| 155 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 156 | pump step function used to pass data from the | ||
| 142 | source to the server. Defaults to the LTN12 <tt>pump.step</tt> function. | 157 | source to the server. Defaults to the LTN12 <tt>pump.step</tt> function. |
| 143 | </ul> | 158 | </ul> |
| 144 | 159 | ||
| @@ -166,7 +181,8 @@ exact opposite of what you expect. | |||
| 166 | Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the | 181 | Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the |
| 167 | message. Each recipient of an SMTP mail message receives a copy of the | 182 | message. Each recipient of an SMTP mail message receives a copy of the |
| 168 | message body along with the headers, and nothing more. The headers | 183 | message body along with the headers, and nothing more. The headers |
| 169 | <em>are</em> part of the message and should be produced by the LTN12 | 184 | <em>are</em> part of the message and should be produced by the |
| 185 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> | ||
| 170 | <tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em> | 186 | <tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em> |
| 171 | part of the message and will not be sent to anyone. | 187 | part of the message and will not be sent to anyone. |
| 172 | </p> | 188 | </p> |
| @@ -258,8 +274,8 @@ smtp.<b>message(</b>mesgt<b>)</b> | |||
| 258 | </p> | 274 | </p> |
| 259 | 275 | ||
| 260 | <p class=description> | 276 | <p class=description> |
| 261 | Returns a LTN12 source that sends an SMTP message body, possibly multipart | 277 | Returns a <em>simple</em> |
| 262 | (arbitrarily deep). | 278 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep). |
| 263 | </p> | 279 | </p> |
| 264 | 280 | ||
| 265 | <p class=parameters> | 281 | <p class=parameters> |
| @@ -277,12 +293,12 @@ mesgt = {<br> | |||
| 277 | }<br> | 293 | }<br> |
| 278 | <br> | 294 | <br> |
| 279 | multipart-mesgt = {<br> | 295 | multipart-mesgt = {<br> |
| 280 | preamble = <i>string</i><br> | 296 | [preamble = <i>string</i>,]<br> |
| 281 | [1] = <i>mesgt</i>,<br> | 297 | [1] = <i>mesgt</i>,<br> |
| 282 | [2] = <i>mesgt</i>,<br> | 298 | [2] = <i>mesgt</i>,<br> |
| 283 | ...<br> | 299 | ...<br> |
| 284 | [<i>n</i>] = <i>mesgt</i>,<br> | 300 | [<i>n</i>] = <i>mesgt</i>,<br> |
| 285 | epilogue = <i>string</i>,<br> | 301 | [epilogue = <i>string</i>,]<br> |
| 286 | }<br> | 302 | }<br> |
| 287 | </tt></td></tr> | 303 | </tt></td></tr> |
| 288 | </table> | 304 | </table> |
| @@ -291,14 +307,19 @@ multipart-mesgt = {<br> | |||
| 291 | <p class=parameters> | 307 | <p class=parameters> |
| 292 | For a simple message, all that is needed is a set of <tt>headers</tt> | 308 | For a simple message, all that is needed is a set of <tt>headers</tt> |
| 293 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string | 309 | and the <tt>body</tt>. The message <tt>body</tt> can be given as a string |
| 294 | or as a LTN12 source. For multipart messages, the body is a table that | 310 | or as a <em>simple</em> |
| 295 | recursively defines each part as an independent message, plus a preamble | 311 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
| 296 | and an epilogue. | 312 | source. For multipart messages, the body is a table that |
| 313 | recursively defines each part as an independent message, plus an optional | ||
| 314 | <tt>preamble</tt> and <tt>epilogue</tt>. | ||
| 297 | </p> | 315 | </p> |
| 298 | 316 | ||
| 299 | <p class=return> | 317 | <p class=return> |
| 300 | The function returns a <em>simple</em> LTN12 source that produces the | 318 | The function returns a <em>simple</em> |
| 301 | message contents as defined by <tt>mesgt</tt>. Hopefully, the following | 319 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> |
| 320 | source that produces the | ||
| 321 | message contents as defined by <tt>mesgt</tt>, chunk by chunk. | ||
| 322 | Hopefully, the following | ||
| 302 | example will make things clear. When in doubt, refer to the appropriate RFC | 323 | example will make things clear. When in doubt, refer to the appropriate RFC |
| 303 | as listed in the introduction. </p> | 324 | as listed in the introduction. </p> |
| 304 | 325 | ||
| @@ -320,7 +341,7 @@ source = smtp.message{ | |||
| 320 | body = { | 341 | body = { |
| 321 | preamble = "If your client doesn't understand attachments, \r\n" .. | 342 | preamble = "If your client doesn't understand attachments, \r\n" .. |
| 322 | "it will still display the preamble and the epilogue.\r\n" .. | 343 | "it will still display the preamble and the epilogue.\r\n" .. |
| 323 | "Preamble might show up even in a MIME enabled client.", | 344 | "Preamble will probably appear even in a MIME enabled client.", |
| 324 | -- first part: no headers means plain text, us-ascii. | 345 | -- first part: no headers means plain text, us-ascii. |
| 325 | -- The mime.eol low-level filter normalizes end-of-line markers. | 346 | -- The mime.eol low-level filter normalizes end-of-line markers. |
| 326 | [1] = { | 347 | [1] = { |
diff --git a/doc/socket.html b/doc/socket.html index b3fbb6e..8b92a3f 100644 --- a/doc/socket.html +++ b/doc/socket.html | |||
| @@ -39,6 +39,16 @@ | |||
| 39 | The <tt>socket</tt> namespace contains the core functionality of LuaSocket. | 39 | The <tt>socket</tt> namespace contains the core functionality of LuaSocket. |
| 40 | </p> | 40 | </p> |
| 41 | 41 | ||
| 42 | <p> | ||
| 43 | To obtain the <tt>socket</tt> namespace, run: | ||
| 44 | </p> | ||
| 45 | |||
| 46 | <pre class=example> | ||
| 47 | -- loads the socket module | ||
| 48 | local socket = require("socket") | ||
| 49 | </pre> | ||
| 50 | |||
| 51 | |||
| 42 | <!-- debug ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 52 | <!-- debug ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 43 | 53 | ||
| 44 | <p class=name id=debug> | 54 | <p class=name id=debug> |
| @@ -62,8 +72,9 @@ Converts a function that throws exceptions into a safe function. | |||
| 62 | </p> | 72 | </p> |
| 63 | 73 | ||
| 64 | <p class=parameters> | 74 | <p class=parameters> |
| 65 | <tt>Funct</tt> is a function that calls | 75 | <tt>Func</tt> is a function that calls |
| 66 | <a href=#try><tt>try</tt></a> to throw exceptions. | 76 | <a href=#try><tt>try</tt></a> (or <tt>assert</tt>, or <tt>error</tt>) |
| 77 | to throw exceptions. | ||
| 67 | </p> | 78 | </p> |
| 68 | 79 | ||
| 69 | <p class=return> | 80 | <p class=return> |
| @@ -71,6 +82,13 @@ Returns an equivalent function that instead of throwing exceptions, | |||
| 71 | returns <tt><b>nil</b></tt> followed by an error message. | 82 | returns <tt><b>nil</b></tt> followed by an error message. |
| 72 | </p> | 83 | </p> |
| 73 | 84 | ||
| 85 | <p class=note> | ||
| 86 | Note: Beware that if your function performs some illegal operation that | ||
| 87 | raises an error, the protected function will catch the error and return it | ||
| 88 | as a string. This is because the <a href=#try><tt>try</tt></a> function | ||
| 89 | uses errors as the mechanism to throw exceptions. | ||
| 90 | </p> | ||
| 91 | |||
| 74 | <!-- select +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 92 | <!-- select +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 75 | 93 | ||
| 76 | <p class=name id=select> | 94 | <p class=name id=select> |
| @@ -88,8 +106,8 @@ see if it is OK to immediately write on them. <tt>Timeout</tt> is the | |||
| 88 | maximum amount of time (in seconds) to wait for a change in status. A | 106 | maximum amount of time (in seconds) to wait for a change in status. A |
| 89 | <tt><b>nil</b></tt>, negative or omitted <tt>timeout</tt> value allows the | 107 | <tt><b>nil</b></tt>, negative or omitted <tt>timeout</tt> value allows the |
| 90 | function to block indefinitely. <tt>Recvt</tt> and <tt>sendt</tt> can also | 108 | function to block indefinitely. <tt>Recvt</tt> and <tt>sendt</tt> can also |
| 91 | be empty tables or <tt><b>nil</b></tt>. Non-socket values in the arrays | 109 | be empty tables or <tt><b>nil</b></tt>. Non-socket values (or values with |
| 92 | will be silently ignored. | 110 | non-numeric indices) in the arrays will be silently ignored. |
| 93 | </p> | 111 | </p> |
| 94 | 112 | ||
| 95 | <p class=return> The function returns a table with the sockets ready for | 113 | <p class=return> The function returns a table with the sockets ready for |
| @@ -186,7 +204,7 @@ The function returns a source with the appropriate behavior. | |||
| 186 | <!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 204 | <!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 187 | 205 | ||
| 188 | <p class=name id=try> | 206 | <p class=name id=try> |
| 189 | socket.<b>try(</b>ret<sub>1</sub>, ret<sub>2</sub> ... ret<sub>N</sub><b>)</b> | 207 | socket.<b>try(</b>ret<sub>1</sub> [, ret<sub>2</sub> ... ret<sub>N</sub>]<b>)</b> |
| 190 | </p> | 208 | </p> |
| 191 | 209 | ||
| 192 | <p class=description> | 210 | <p class=description> |
| @@ -194,16 +212,14 @@ Throws an exception in case of error. | |||
| 194 | </p> | 212 | </p> |
| 195 | 213 | ||
| 196 | <p class=parameters> | 214 | <p class=parameters> |
| 197 | <tt>Ret</tt><sub>1</sub>, <tt>ret</tt><sub>2</sub> ... <tt>ret</tt><sub>N</sub> can be arbitrary | 215 | <tt>Ret</tt><sub>1</sub> to <tt>ret</tt><sub>N</sub> can be arbitrary |
| 198 | arguments, but are usually the return values of a function call that | 216 | arguments, but are usually the return values of a function call |
| 199 | nested with the call to <tt>try</tt>. | 217 | nested with <tt>try</tt>. |
| 200 | </p> | 218 | </p> |
| 201 | 219 | ||
| 202 | <p class=return> | 220 | <p class=return> |
| 203 | The function returns <tt>ret</tt><sub>1</sub>, <tt>ret</tt><sub>2</sub> ... | 221 | The function returns <tt>ret</tt><sub>1</sub> to <tt>ret</tt><sub>N</sub> if |
| 204 | <tt>ret</tt><sub>N</sub> if | 222 | <tt>ret</tt><sub>1</sub> is not <tt><b>nil</b></tt>. Otherwise, it calls <tt>error</tt> passing <tt>ret</tt><sub>2</sub>. |
| 205 | <tt>ret</tt><sub>1</sub> is not <tt><b>nil</b></tt>. Otherwise, calls <tt>error</tt> | ||
| 206 | passing <tt>ret</tt><sub>2</sub>. | ||
| 207 | </p> | 223 | </p> |
| 208 | 224 | ||
| 209 | <pre class=example> | 225 | <pre class=example> |
| @@ -211,7 +227,7 @@ passing <tt>ret</tt><sub>2</sub>. | |||
| 211 | c = socket.try(socket.connect("localhost", 80)) | 227 | c = socket.try(socket.connect("localhost", 80)) |
| 212 | </pre> | 228 | </pre> |
| 213 | 229 | ||
| 214 | <!-- version ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 230 | <!-- version ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 215 | 231 | ||
| 216 | <p class=name id=version> | 232 | <p class=name id=version> |
| 217 | socket.<b>VERSION</b> | 233 | socket.<b>VERSION</b> |
