diff options
Diffstat (limited to 'doc/socket.html')
| -rw-r--r-- | doc/socket.html | 66 |
1 files changed, 65 insertions, 1 deletions
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> |
