diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-18 08:02:09 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-18 08:02:09 +0000 |
| commit | ac4aac0909da26befaaeb6b415f66cf35b6980e0 (patch) | |
| tree | 3d3289e6192508484dcbefa10e2d862c5cc06d64 /doc | |
| parent | 62799a416d2b29d8058331f3d8725fb67c75d261 (diff) | |
| download | luasocket-ac4aac0909da26befaaeb6b415f66cf35b6980e0.tar.gz luasocket-ac4aac0909da26befaaeb6b415f66cf35b6980e0.tar.bz2 luasocket-ac4aac0909da26befaaeb6b415f66cf35b6980e0.zip | |
Implemented safe exceptions. This looks preeety good.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/reference.html | 3 | ||||
| -rw-r--r-- | doc/socket.html | 66 | ||||
| -rw-r--r-- | doc/tcp.html | 28 |
3 files changed, 84 insertions, 13 deletions
diff --git a/doc/reference.html b/doc/reference.html index 607958b..f130d7b 100644 --- a/doc/reference.html +++ b/doc/reference.html | |||
| @@ -143,8 +143,9 @@ | |||
| 143 | <a href="socket.html#protect">protect</a>, | 143 | <a href="socket.html#protect">protect</a>, |
| 144 | <a href="socket.html#select">select</a>, | 144 | <a href="socket.html#select">select</a>, |
| 145 | <a href="socket.html#sink">sink</a>, | 145 | <a href="socket.html#sink">sink</a>, |
| 146 | <a href="socket.html#source">source</a>, | 146 | <a href="socket.html#skip">skip</a>, |
| 147 | <a href="socket.html#sleep">sleep</a>, | 147 | <a href="socket.html#sleep">sleep</a>, |
| 148 | <a href="socket.html#source">source</a>, | ||
| 148 | <a href="socket.html#time">time</a>, | 149 | <a href="socket.html#time">time</a>, |
| 149 | <a href="tcp.html#tcp">tcp</a>, | 150 | <a href="tcp.html#tcp">tcp</a>, |
| 150 | <a href="socket.html#try">try</a>, | 151 | <a href="socket.html#try">try</a>, |
diff --git a/doc/socket.html b/doc/socket.html index d7739f8..06296a3 100644 --- a/doc/socket.html +++ b/doc/socket.html | |||
| @@ -169,6 +169,49 @@ socket, leaving it open when done. | |||
| 169 | The function returns a sink with the appropriate behavior. | 169 | The function returns a sink with the appropriate behavior. |
| 170 | </p> | 170 | </p> |
| 171 | 171 | ||
| 172 | <!-- skip ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 173 | |||
| 174 | <p class=name id=skip> | ||
| 175 | socket.<b>skip(</b>d [, ret<sub>1</sub>, ret<sub>2</sub> ... ret<sub>N</sub>]<b>)</b> | ||
| 176 | </p> | ||
| 177 | |||
| 178 | <p class=description> | ||
| 179 | Drops a number of arguments and returns the remaining. | ||
| 180 | </p> | ||
| 181 | |||
| 182 | <p class=parameters> | ||
| 183 | <tt>D</tt> is the number of arguments to drop. <tt>Ret<sub>1</sub></tt> to | ||
| 184 | <tt>ret<sub>N</sub></tt> are the arguments. | ||
| 185 | </p> | ||
| 186 | |||
| 187 | <p class=return> | ||
| 188 | The function returns <tt>ret<sub>d+1</sub></tt> to <tt>ret<sub>N</sub></tt>. | ||
| 189 | </p> | ||
| 190 | |||
| 191 | <p class=note> | ||
| 192 | Note: This function is useful to avoid creation of dummy variables: | ||
| 193 | </p> | ||
| 194 | |||
| 195 | <pre class=example> | ||
| 196 | -- get the status code and separator from SMTP server reply | ||
| 197 | local code, sep = socket.skip(2, string.find(line, "^(%d%d%d)(.?)")) | ||
| 198 | </pre> | ||
| 199 | |||
| 200 | <!-- sleep ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 201 | |||
| 202 | <p class=name id=sleep> | ||
| 203 | socket.<b>sleep(</b>time<b>)</b> | ||
| 204 | </p> | ||
| 205 | |||
| 206 | <p class=description> | ||
| 207 | Freezes the program execution during a given amount of time. | ||
| 208 | </p> | ||
| 209 | |||
| 210 | <p class=parameters> | ||
| 211 | <tt>Time</tt> is the number of seconds to sleep for. | ||
| 212 | The function truncates <tt>time</tt> to the nearest integer. | ||
| 213 | </p> | ||
| 214 | |||
| 172 | <!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 215 | <!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 173 | 216 | ||
| 174 | <p class=name id=source> | 217 | <p class=name id=source> |
| @@ -201,6 +244,27 @@ side closes the connection. | |||
| 201 | The function returns a source with the appropriate behavior. | 244 | The function returns a source with the appropriate behavior. |
| 202 | </p> | 245 | </p> |
| 203 | 246 | ||
| 247 | <!-- time ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 248 | |||
| 249 | <p class=name id=time> | ||
| 250 | socket.<b>time()</b> | ||
| 251 | </p> | ||
| 252 | |||
| 253 | <p class=description> | ||
| 254 | Returns the time in seconds, relative to the origin of the | ||
| 255 | universe. Only time differences are meaninful. | ||
| 256 | </p> | ||
| 257 | |||
| 258 | <p class=return> | ||
| 259 | The function returns the time as a number. | ||
| 260 | </p> | ||
| 261 | |||
| 262 | <pre class=example> | ||
| 263 | t = socket.time() | ||
| 264 | -- do stuff | ||
| 265 | print(socket.time() - t .. " seconds elapsed") | ||
| 266 | </pre> | ||
| 267 | |||
| 204 | <!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 268 | <!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 205 | 269 | ||
| 206 | <p class=name id=try> | 270 | <p class=name id=try> |
| @@ -212,7 +276,7 @@ Throws an exception in case of error. | |||
| 212 | </p> | 276 | </p> |
| 213 | 277 | ||
| 214 | <p class=parameters> | 278 | <p class=parameters> |
| 215 | <tt>Ret</tt><sub>1</sub> to <tt>ret</tt><sub>N</sub> can be arbitrary | 279 | <tt>Ret<sub>1</sub></tt> to <tt>ret<sub>N</sub></tt> can be arbitrary |
| 216 | arguments, but are usually the return values of a function call | 280 | arguments, but are usually the return values of a function call |
| 217 | nested with <tt>try</tt>. | 281 | nested with <tt>try</tt>. |
| 218 | </p> | 282 | </p> |
diff --git a/doc/tcp.html b/doc/tcp.html index 781ec6f..cd417a5 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
| @@ -277,9 +277,10 @@ the transmission. | |||
| 277 | <p class=note> | 277 | <p class=note> |
| 278 | <b>Important note</b>: This function was changed <em>severely</em>. It used | 278 | <b>Important note</b>: This function was changed <em>severely</em>. It used |
| 279 | to support multiple patterns (but I have never seen this feature used) and | 279 | to support multiple patterns (but I have never seen this feature used) and |
| 280 | partial results used to be returned in the same way as successful results. | 280 | now it doesn't anymore. Partial results used to be returned in the same |
| 281 | This last feature violated the idea that all functions should return | 281 | way as successful results. This last feature violated the idea that all |
| 282 | <tt><b>nil</b></tt> on error. Thus the change. | 282 | functions should return <tt><b>nil</b></tt> on error. Thus it was changed |
| 283 | too. | ||
| 283 | </p> | 284 | </p> |
| 284 | 285 | ||
| 285 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 286 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -300,20 +301,25 @@ result to LuaSocket instead of passing several independent strings. | |||
| 300 | </p> | 301 | </p> |
| 301 | 302 | ||
| 302 | <p class=return> | 303 | <p class=return> |
| 303 | The method returns the number of bytes accepted by the transport layer, | 304 | If successful, the method returns the number of bytes accepted by |
| 304 | followed by an error code. The error code is <b><tt>nil</tt></b> if the operation | 305 | the transport layer. In case of error, the method returns |
| 305 | completed with no errors, the string '<tt>closed</tt>' in case | 306 | <b><tt>nil</tt></b>, followed by an error message, followed by the |
| 307 | partial number of bytes accepted by the transport layer. | ||
| 308 | The error message can be '<tt>closed</tt>' in case | ||
| 306 | the connection was closed before the transmission was completed or the | 309 | the connection was closed before the transmission was completed or the |
| 307 | string '<tt>timeout</tt>' in case there was a timeout during the | 310 | string '<tt>timeout</tt>' in case there was a timeout during the |
| 308 | operation. | 311 | operation. |
| 309 | </p> | 312 | </p> |
| 310 | 313 | ||
| 311 | <p class=note> | 314 | <p class=note> |
| 312 | Note: The return values for the <tt>send</tt> method have been changed in | 315 | <b>Important note</b>: |
| 313 | LuaSocket 2.0! In previous versions, the method returned only the | 316 | The return values for the <tt>send</tt> method have been changed in |
| 314 | error message. Since returning <b><tt>nil</tt></b> in case of success goes | 317 | LuaSocket 2.0 alpha <b>and again</b> in the beta (sorry)! |
| 315 | against all other LuaSocket methods and functions, the | 318 | In previous versions, the method returned only the |
| 316 | <tt>send</tt> method been changed for the sake of uniformity. | 319 | error message. Since returning <b><tt>nil</tt></b> in case of success was |
| 320 | nonsense, in alpha the first return value became the number of bytes sent. | ||
| 321 | Alas, it wasn't returning <tt><b>nil</b></tt> in case of | ||
| 322 | error. So it was changed again in beta. | ||
| 317 | </p> | 323 | </p> |
| 318 | 324 | ||
| 319 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 325 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
