diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-26 04:58:32 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-26 04:58:32 +0000 |
commit | bf738a03368b8de9c574d9631f131c5a520acf7b (patch) | |
tree | a65c512ce4601b056417ff7154ebdc254d762054 /doc | |
parent | 4b7c2db4b7109bf57abd1b76abf24eba27f51aa1 (diff) | |
download | luasocket-bf738a03368b8de9c574d9631f131c5a520acf7b.tar.gz luasocket-bf738a03368b8de9c574d9631f131c5a520acf7b.tar.bz2 luasocket-bf738a03368b8de9c574d9631f131c5a520acf7b.zip |
Working with in the manual.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/reference.html | 57 | ||||
-rw-r--r-- | doc/socket.html | 117 |
2 files changed, 144 insertions, 30 deletions
diff --git a/doc/reference.html b/doc/reference.html index 6372e64..ba519c0 100644 --- a/doc/reference.html +++ b/doc/reference.html | |||
@@ -55,10 +55,10 @@ | |||
55 | </blockquote> | 55 | </blockquote> |
56 | </blockquote> | 56 | </blockquote> |
57 | 57 | ||
58 | <!-- misc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 58 | <!-- global +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
59 | 59 | ||
60 | <blockquote> | 60 | <blockquote> |
61 | <a href="global.html">Globals</a> | 61 | <a href="global.html">Global symbols</a> |
62 | <blockquote> | 62 | <blockquote> |
63 | <a href="global.html#LUASOCKET_LIBNAME">LUASOCKET_LIBNAME</a>, | 63 | <a href="global.html#LUASOCKET_LIBNAME">LUASOCKET_LIBNAME</a>, |
64 | <a href="global.html#mime">mime</a>, | 64 | <a href="global.html#mime">mime</a>, |
@@ -68,32 +68,6 @@ | |||
68 | </blockquote> | 68 | </blockquote> |
69 | </table> | 69 | </table> |
70 | 70 | ||
71 | <blockquote> | ||
72 | <a href="socket.html">LuaSocket namespace (socket)</a> | ||
73 | <blockquote> | ||
74 | <a href="socket.html#bind">bind</a>, | ||
75 | <a href="socket.html#connect">connect</a>, | ||
76 | <a href="socket.html#debug">debug</a>, | ||
77 | <a href="socket.html#dns">dns</a>, | ||
78 | <a href="socket.html#ftp">ftp</a>, | ||
79 | <a href="socket.html#http">http</a>, | ||
80 | <a href="socket.html#protect">protect</a>, | ||
81 | <a href="socket.html#select">select</a>, | ||
82 | <a href="socket.html#sink">sink</a>, | ||
83 | <a href="socket.html#source">source</a>, | ||
84 | <a href="socket.html#sleep">sleep</a>, | ||
85 | <a href="socket.html#smtp">smtp</a>, | ||
86 | <a href="socket.html#time">time</a>, | ||
87 | <a href="socket.html#tcp">tcp</a>, | ||
88 | <a href="socket.html#try">try</a>, | ||
89 | <a href="socket.html#udp">udp</a>, | ||
90 | <a href="socket.html#url">url</a>, | ||
91 | <a href="socket.html#version">version</a>. | ||
92 | </blockquote> | ||
93 | </blockquote> | ||
94 | </table> | ||
95 | |||
96 | |||
97 | <!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 71 | <!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
98 | 72 | ||
99 | <blockquote> | 73 | <blockquote> |
@@ -175,6 +149,33 @@ | |||
175 | </blockquote> | 149 | </blockquote> |
176 | </blockquote> | 150 | </blockquote> |
177 | 151 | ||
152 | <!-- socket +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
153 | |||
154 | <blockquote> | ||
155 | <a href="socket.html">The socket namespace (socket)</a> | ||
156 | <blockquote> | ||
157 | <a href="tcp.html#bind">bind</a>, | ||
158 | <a href="tcp.html#connect">connect</a>, | ||
159 | <a href="socket.html#debug">debug</a>, | ||
160 | <a href="dns.html#dns">dns</a>, | ||
161 | <a href="ftp.html#ftp">ftp</a>, | ||
162 | <a href="http.html#http">http</a>, | ||
163 | <a href="socket.html#protect">protect</a>, | ||
164 | <a href="socket.html#select">select</a>, | ||
165 | <a href="socket.html#sink">sink</a>, | ||
166 | <a href="socket.html#source">source</a>, | ||
167 | <a href="socket.html#sleep">sleep</a>, | ||
168 | <a href="smtp.html#smtp">smtp</a>, | ||
169 | <a href="socket.html#time">time</a>, | ||
170 | <a href="tcp.html#tcp">tcp</a>, | ||
171 | <a href="socket.html#try">try</a>, | ||
172 | <a href="udp.html#udp">udp</a>, | ||
173 | <a href="url.html#url">url</a>, | ||
174 | <a href="socket.html#version">version</a>. | ||
175 | </blockquote> | ||
176 | </blockquote> | ||
177 | </table> | ||
178 | |||
178 | <!-- tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 179 | <!-- tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
179 | 180 | ||
180 | <blockquote> | 181 | <blockquote> |
diff --git a/doc/socket.html b/doc/socket.html index 9372648..bde882b 100644 --- a/doc/socket.html +++ b/doc/socket.html | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | <!-- socket +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 34 | <!-- socket +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
35 | 35 | ||
36 | <h2 id=socket>The LuaSocket namespace</h2> | 36 | <h2 id=socket>The socket namespace</h2> |
37 | 37 | ||
38 | <p> | 38 | <p> |
39 | The <tt>socket</tt> namespace contains the namespace tables for all | 39 | The <tt>socket</tt> namespace contains the namespace tables for all |
@@ -74,7 +74,120 @@ The function an equivalent function that instead of throwing exceptoins, | |||
74 | returns <tt><b>nil</b></tt> followed by an error message. | 74 | returns <tt><b>nil</b></tt> followed by an error message. |
75 | </p> | 75 | </p> |
76 | 76 | ||
77 | <!-- toip +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 77 | <!-- select +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
78 | |||
79 | <p class=name id=select> | ||
80 | socket.<b>select(</b>recvt, sendt [, timeout]<b>)</b> | ||
81 | </p> | ||
82 | |||
83 | <p class=description> | ||
84 | Waits for a number of sockets to change status. | ||
85 | </p> | ||
86 | |||
87 | <p class=parameters> | ||
88 | <tt>Recvt</tt> is an array with the sockets to test for characters | ||
89 | available for reading. Sockets in the <tt>sendt</tt> array are watched to | ||
90 | see if it is OK to immediately write on them. <tt>Timeout</tt> is the | ||
91 | maximum amount of time (in seconds) to wait for a change in status. A | ||
92 | <tt><b>nil</b></tt>, negative or omitted <tt>timeout</tt> value allows the | ||
93 | function to block indefinitely. <tt>Recvt</tt> and <tt>sendt</tt> can also | ||
94 | be empty tables or <tt><b>nil</b></tt>. Non-socket values in the arrays | ||
95 | will be silently ignored. | ||
96 | </p> | ||
97 | |||
98 | <p class=return> The function returns a table with the sockets ready for | ||
99 | reading, a table with the sockets ready for writing and an error message. | ||
100 | The error message is "<tt>timeout</tt>" if a timeout condition was met and | ||
101 | <tt><b>nil</b></tt> otherwise. The returned tables are associative, to | ||
102 | simplify the test if a specific socket has changed status. | ||
103 | </p> | ||
104 | |||
105 | <p class=note> | ||
106 | <b>Important Note</b>: a known bug in WinSock causes <tt>select</tt> to fail | ||
107 | on non-blocking TCP sockets. The function may return a socket as | ||
108 | writable even though the socket is <em>not</em> ready for sending. | ||
109 | </p> | ||
110 | |||
111 | <p class=note> | ||
112 | <b>Important note</b>: calling select with a server socket in the receive | ||
113 | parameter before a call to accept does <em>not</em> guarantee | ||
114 | <a href=tcp.html#accept><tt>accept</tt></a> will return immediately. | ||
115 | Use the <a href=tcp.html#timeout><tt>timeout</tt></a> | ||
116 | method or <tt>accept</tt> might block forever. | ||
117 | </p> | ||
118 | |||
119 | <p class=note> | ||
120 | Interesting note: as mentioned in some manuals, calling select with both | ||
121 | sets empty and a non-null timeout is a fairly portable way to sleep with | ||
122 | sub-second precision. | ||
123 | </p> | ||
124 | |||
125 | |||
126 | <!-- sink ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
127 | |||
128 | <p class=name id=sink> | ||
129 | socket.<b>sink(</b>mode, socket<b>)</b> | ||
130 | </p> | ||
131 | |||
132 | <p class=description> | ||
133 | Creates an | ||
134 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN012</a> | ||
135 | sink from a stream socket object. | ||
136 | </p> | ||
137 | |||
138 | <p class=parameters> | ||
139 | <tt>Mode</tt> defines the behaviour of the sink. The following | ||
140 | options are available: | ||
141 | </p> | ||
142 | <ul> | ||
143 | <li> <tt>"http-chunked"</tt>: sends data through socket after applying the | ||
144 | <em>chunked transfer coding</em>, closing the socket when done; | ||
145 | <li> <tt>"close-when-done"</tt>: sends all received data through the | ||
146 | socket, closing the socket when done; | ||
147 | <li> <tt>"keep-open"</tt>: sends all received data through the | ||
148 | socket, leaving it open when done. | ||
149 | </ul> | ||
150 | <p> | ||
151 | <tt>Socket</tt> is the stream socket object used to send the data. | ||
152 | </p> | ||
153 | |||
154 | <p class=return> | ||
155 | The function returns a sink with the appropriate behavior. | ||
156 | </p> | ||
157 | |||
158 | <!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
159 | |||
160 | <p class=name id=source> | ||
161 | socket.<b>source(</b>mode, socket [, length]<b>)</b> | ||
162 | </p> | ||
163 | |||
164 | <p class=description> | ||
165 | Creates an | ||
166 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN012</a> | ||
167 | source from a stream socket object. | ||
168 | </p> | ||
169 | |||
170 | <p class=parameters> | ||
171 | <tt>Mode</tt> defines the behaviour of the source. The following | ||
172 | options are available: | ||
173 | </p> | ||
174 | <ul> | ||
175 | <li> <tt>"http-chunked"</tt>: receives data from socket and removes the | ||
176 | <em>chunked transfer coding</em> before returning the data; | ||
177 | <li> <tt>"by-length"</tt>: receives a fixed number of bytes from the | ||
178 | socket. This mode requires the extra argument <tt>length</tt>; | ||
179 | <li> <tt>"until-closed"</tt>: receives data from a socket until the other | ||
180 | side closes the connection. | ||
181 | </ul> | ||
182 | <p> | ||
183 | <tt>Socket</tt> is the stream socket object used to receive the data. | ||
184 | </p> | ||
185 | |||
186 | <p class=return> | ||
187 | The function returns a source with the appropriate behavior. | ||
188 | </p> | ||
189 | |||
190 | <!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
78 | 191 | ||
79 | <p class=name id=try> | 192 | <p class=name id=try> |
80 | socket.<b>try(</b>ret<sub>1</sub>, ret<sub>2</sub> ... ret<sub>N</sub><b>)</b> | 193 | socket.<b>try(</b>ret<sub>1</sub>, ret<sub>2</sub> ... ret<sub>N</sub><b>)</b> |