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 /doc/socket.html | |
parent | 0a4c1534f39511894728da193ab8225ad6022de9 (diff) | |
download | luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.tar.gz luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.tar.bz2 luasocket-ba2f0b8c6ba7fb3a26fa6d9676ee1aefe6d873cc.zip |
Fine tuning the manual...
Diffstat (limited to '')
-rw-r--r-- | doc/socket.html | 42 |
1 files changed, 29 insertions, 13 deletions
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> |