diff options
author | Diego Nehab <diego@impa.br> | 2015-08-22 19:52:01 -0300 |
---|---|---|
committer | Diego Nehab <diego@impa.br> | 2015-08-22 19:52:01 -0300 |
commit | 96965b179c7311f850f72a8629b9ba6d3a31d117 (patch) | |
tree | 05c93629654f686a99ee8923ef2361b7d2244ca8 /doc/tcp.html | |
parent | b211838648c1cb092e96e3ae721932a212808d96 (diff) | |
download | luasocket-96965b179c7311f850f72a8629b9ba6d3a31d117.tar.gz luasocket-96965b179c7311f850f72a8629b9ba6d3a31d117.tar.bz2 luasocket-96965b179c7311f850f72a8629b9ba6d3a31d117.zip |
New agnostic IPv4 IPv6 functions.
Also dealing with EPROTOTYPE Yosemite seems to be throwing
at us for no reason.
Diffstat (limited to 'doc/tcp.html')
-rw-r--r-- | doc/tcp.html | 193 |
1 files changed, 110 insertions, 83 deletions
diff --git a/doc/tcp.html b/doc/tcp.html index 4226d78..6fc9900 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
@@ -1,10 +1,10 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 | "http://www.w3.org/TR/html4/strict.dtd"> | 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <meta name="description" content="LuaSocket: The TCP/IP support"> | 6 | <meta name="description" content="LuaSocket: The TCP/IP support"> |
7 | <meta name="keywords" content="Lua, LuaSocket, Socket, TCP, Library, Network, Support"> | 7 | <meta name="keywords" content="Lua, LuaSocket, Socket, TCP, Library, Network, Support"> |
8 | <title>LuaSocket: TCP/IP support</title> | 8 | <title>LuaSocket: TCP/IP support</title> |
9 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
10 | </head> | 10 | </head> |
@@ -28,7 +28,7 @@ | |||
28 | <a href="index.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
32 | </p> | 32 | </p> |
33 | </center> | 33 | </center> |
34 | <hr> | 34 | <hr> |
@@ -36,21 +36,48 @@ | |||
36 | 36 | ||
37 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 37 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
38 | 38 | ||
39 | <h2 id="tcp">TCP</h2> | 39 | <h2 id="tcp">TCP</h2> |
40 | 40 | ||
41 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 41 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
42 | 42 | ||
43 | <p class=name id="socket.tcp"> | 43 | <p class=name id="socket.tcp"> |
44 | socket.<b>tcp()</b> | 44 | socket.<b>tcp()</b> |
45 | </p> | 45 | </p> |
46 | 46 | ||
47 | <p class=description> | 47 | <p class=description> |
48 | Creates and returns an TCP master object. A master object can | ||
49 | be transformed into a server object with the method | ||
50 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
51 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
52 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
53 | method supported by a master object is the | ||
54 | <a href=#close><tt>close</tt></a> method.</p> | ||
55 | |||
56 | <p class=return> | ||
57 | In case of success, a new master object is returned. In case of error, | ||
58 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
59 | </p> | ||
60 | |||
61 | <p class=note> | ||
62 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
63 | <a href=#bind><tt>bind</tt></a> or <a | ||
64 | href=#bind><tt>connect</tt></a>, depending on the address | ||
65 | family obtained from the resolver. | ||
66 | </p> | ||
67 | |||
68 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
69 | |||
70 | <p class=name id="socket.tcp4"> | ||
71 | socket.<b>tcp4()</b> | ||
72 | </p> | ||
73 | |||
74 | <p class=description> | ||
48 | Creates and returns an IPv4 TCP master object. A master object can | 75 | Creates and returns an IPv4 TCP master object. A master object can |
49 | be transformed into a server object with the method | 76 | be transformed into a server object with the method |
50 | <a href=#listen><tt>listen</tt></a> (after a call to <a | 77 | <a href=#listen><tt>listen</tt></a> (after a call to <a |
51 | href=#bind><tt>bind</tt></a>) or into a client object with | 78 | href=#bind><tt>bind</tt></a>) or into a client object with |
52 | the method <a href=#connect><tt>connect</tt></a>. The only other | 79 | the method <a href=#connect><tt>connect</tt></a>. The only other |
53 | method supported by a master object is the | 80 | method supported by a master object is the |
54 | <a href=#close><tt>close</tt></a> method.</p> | 81 | <a href=#close><tt>close</tt></a> method.</p> |
55 | 82 | ||
56 | <p class=return> | 83 | <p class=return> |
@@ -60,17 +87,17 @@ In case of success, a new master object is returned. In case of error, | |||
60 | 87 | ||
61 | <!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 88 | <!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
62 | 89 | ||
63 | <p class=name id="socket.tcp6"> | 90 | <p class=name id="socket.tcp6"> |
64 | socket.<b>tcp6()</b> | 91 | socket.<b>tcp6()</b> |
65 | </p> | 92 | </p> |
66 | 93 | ||
67 | <p class=description> | 94 | <p class=description> |
68 | Creates and returns an IPv6 TCP master object. A master object can | 95 | Creates and returns an IPv6 TCP master object. A master object can |
69 | be transformed into a server object with the method | 96 | be transformed into a server object with the method |
70 | <a href=#listen><tt>listen</tt></a> (after a call to <a | 97 | <a href=#listen><tt>listen</tt></a> (after a call to <a |
71 | href=#bind><tt>bind</tt></a>) or into a client object with | 98 | href=#bind><tt>bind</tt></a>) or into a client object with |
72 | the method <a href=#connect><tt>connect</tt></a>. The only other | 99 | the method <a href=#connect><tt>connect</tt></a>. The only other |
73 | method supported by a master object is the | 100 | method supported by a master object is the |
74 | <a href=#close><tt>close</tt></a> method.</p> | 101 | <a href=#close><tt>close</tt></a> method.</p> |
75 | 102 | ||
76 | <p class=return> | 103 | <p class=return> |
@@ -85,7 +112,7 @@ Note: The TCP object returned will have the option | |||
85 | 112 | ||
86 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 113 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
87 | 114 | ||
88 | <p class=name id="accept"> | 115 | <p class=name id="accept"> |
89 | server:<b>accept()</b> | 116 | server:<b>accept()</b> |
90 | </p> | 117 | </p> |
91 | 118 | ||
@@ -95,9 +122,9 @@ object and returns a client object representing that connection. | |||
95 | </p> | 122 | </p> |
96 | 123 | ||
97 | <p class=return> | 124 | <p class=return> |
98 | If a connection is successfully initiated, a client object is returned. | 125 | If a connection is successfully initiated, a client object is returned. |
99 | If a timeout condition is met, the method returns <b><tt>nil</tt></b> | 126 | If a timeout condition is met, the method returns <b><tt>nil</tt></b> |
100 | followed by the error string '<tt>timeout</tt>'. Other errors are | 127 | followed by the error string '<tt>timeout</tt>'. Other errors are |
101 | reported by <b><tt>nil</tt></b> followed by a message describing the error. | 128 | reported by <b><tt>nil</tt></b> followed by a message describing the error. |
102 | </p> | 129 | </p> |
103 | 130 | ||
@@ -107,28 +134,28 @@ with a server object in | |||
107 | the <tt>recvt</tt> parameter before a call to <tt>accept</tt> does | 134 | the <tt>recvt</tt> parameter before a call to <tt>accept</tt> does |
108 | <em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a | 135 | <em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a |
109 | href=#settimeout><tt>settimeout</tt></a> method or <tt>accept</tt> | 136 | href=#settimeout><tt>settimeout</tt></a> method or <tt>accept</tt> |
110 | might block until <em>another</em> client shows up. | 137 | might block until <em>another</em> client shows up. |
111 | </p> | 138 | </p> |
112 | 139 | ||
113 | <!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 140 | <!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
114 | 141 | ||
115 | <p class=name id="bind"> | 142 | <p class=name id="bind"> |
116 | master:<b>bind(</b>address, port<b>)</b> | 143 | master:<b>bind(</b>address, port<b>)</b> |
117 | </p> | 144 | </p> |
118 | 145 | ||
119 | <p class=description> | 146 | <p class=description> |
120 | Binds a master object to <tt>address</tt> and <tt>port</tt> on the | 147 | Binds a master object to <tt>address</tt> and <tt>port</tt> on the |
121 | local host. | 148 | local host. |
122 | 149 | ||
123 | <p class=parameters> | 150 | <p class=parameters> |
124 | <tt>Address</tt> can be an IP address or a host name. | 151 | <tt>Address</tt> can be an IP address or a host name. |
125 | <tt>Port</tt> must be an integer number in the range [0..64K). | 152 | <tt>Port</tt> must be an integer number in the range [0..64K). |
126 | If <tt>address</tt> | 153 | If <tt>address</tt> |
127 | is '<tt>*</tt>', the system binds to all local interfaces | 154 | is '<tt>*</tt>', the system binds to all local interfaces |
128 | using the <tt>INADDR_ANY</tt> constant or | 155 | using the <tt>INADDR_ANY</tt> constant or |
129 | <tt>IN6ADDR_ANY_INIT</tt>, according to the family. | 156 | <tt>IN6ADDR_ANY_INIT</tt>, according to the family. |
130 | If <tt>port</tt> is 0, the system automatically | 157 | If <tt>port</tt> is 0, the system automatically |
131 | chooses an ephemeral port. | 158 | chooses an ephemeral port. |
132 | </p> | 159 | </p> |
133 | 160 | ||
134 | <p class=return> | 161 | <p class=return> |
@@ -137,13 +164,13 @@ method returns <b><tt>nil</tt></b> followed by an error message. | |||
137 | </p> | 164 | </p> |
138 | 165 | ||
139 | <p class=note> | 166 | <p class=note> |
140 | Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a> | 167 | Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a> |
141 | is available and is a shortcut for the creation of server sockets. | 168 | is available and is a shortcut for the creation of server sockets. |
142 | </p> | 169 | </p> |
143 | 170 | ||
144 | <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 171 | <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
145 | 172 | ||
146 | <p class=name id="close"> | 173 | <p class=name id="close"> |
147 | master:<b>close()</b><br> | 174 | master:<b>close()</b><br> |
148 | client:<b>close()</b><br> | 175 | client:<b>close()</b><br> |
149 | server:<b>close()</b> | 176 | server:<b>close()</b> |
@@ -154,14 +181,14 @@ Closes a TCP object. The internal socket used by the object is closed | |||
154 | and the local address to which the object was | 181 | and the local address to which the object was |
155 | bound is made available to other applications. No further operations | 182 | bound is made available to other applications. No further operations |
156 | (except for further calls to the <tt>close</tt> method) are allowed on | 183 | (except for further calls to the <tt>close</tt> method) are allowed on |
157 | a closed socket. | 184 | a closed socket. |
158 | </p> | 185 | </p> |
159 | 186 | ||
160 | <p class=note> | 187 | <p class=note> |
161 | Note: It is important to close all used sockets once they are not | 188 | Note: It is important to close all used sockets once they are not |
162 | needed, since, in many systems, each socket uses a file descriptor, | 189 | needed, since, in many systems, each socket uses a file descriptor, |
163 | which are limited system resources. Garbage-collected objects are | 190 | which are limited system resources. Garbage-collected objects are |
164 | automatically closed before destruction, though. | 191 | automatically closed before destruction, though. |
165 | </p> | 192 | </p> |
166 | 193 | ||
167 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 194 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -172,19 +199,19 @@ master:<b>connect(</b>address, port<b>)</b> | |||
172 | 199 | ||
173 | <p class=description> | 200 | <p class=description> |
174 | Attempts to connect a master object to a remote host, transforming it into a | 201 | Attempts to connect a master object to a remote host, transforming it into a |
175 | client object. | 202 | client object. |
176 | Client objects support methods | 203 | Client objects support methods |
177 | <a href=#send><tt>send</tt></a>, | 204 | <a href=#send><tt>send</tt></a>, |
178 | <a href=#receive><tt>receive</tt></a>, | 205 | <a href=#receive><tt>receive</tt></a>, |
179 | <a href=#getsockname><tt>getsockname</tt></a>, | 206 | <a href=#getsockname><tt>getsockname</tt></a>, |
180 | <a href=#getpeername><tt>getpeername</tt></a>, | 207 | <a href=#getpeername><tt>getpeername</tt></a>, |
181 | <a href=#settimeout><tt>settimeout</tt></a>, | 208 | <a href=#settimeout><tt>settimeout</tt></a>, |
182 | and <a href=#close><tt>close</tt></a>. | 209 | and <a href=#close><tt>close</tt></a>. |
183 | </p> | 210 | </p> |
184 | 211 | ||
185 | <p class=parameters> | 212 | <p class=parameters> |
186 | <tt>Address</tt> can be an IP address or a host name. | 213 | <tt>Address</tt> can be an IP address or a host name. |
187 | <tt>Port</tt> must be an integer number in the range [1..64K). | 214 | <tt>Port</tt> must be an integer number in the range [1..64K). |
188 | </p> | 215 | </p> |
189 | 216 | ||
190 | <p class=return> | 217 | <p class=return> |
@@ -193,14 +220,14 @@ describing the error. In case of success, the method returns 1. | |||
193 | </p> | 220 | </p> |
194 | 221 | ||
195 | <p class=note> | 222 | <p class=note> |
196 | Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a> | 223 | Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a> |
197 | is available and is a shortcut for the creation of client sockets. | 224 | is available and is a shortcut for the creation of client sockets. |
198 | </p> | 225 | </p> |
199 | 226 | ||
200 | <p class=note> | 227 | <p class=note> |
201 | Note: Starting with LuaSocket 2.0, | 228 | Note: Starting with LuaSocket 2.0, |
202 | the <a href=#settimeout><tt>settimeout</tt></a> | 229 | the <a href=#settimeout><tt>settimeout</tt></a> |
203 | method affects the behavior of <tt>connect</tt>, causing it to return | 230 | method affects the behavior of <tt>connect</tt>, causing it to return |
204 | with an error in case of a timeout. If that happens, you can still call <a | 231 | with an error in case of a timeout. If that happens, you can still call <a |
205 | href=socket.html#select><tt>socket.select</tt></a> with the socket in the | 232 | href=socket.html#select><tt>socket.select</tt></a> with the socket in the |
206 | <tt>sendt</tt> table. The socket will be writable when the connection is | 233 | <tt>sendt</tt> table. The socket will be writable when the connection is |
@@ -227,10 +254,10 @@ Returns information about the remote side of a connected client object. | |||
227 | </p> | 254 | </p> |
228 | 255 | ||
229 | <p class=return> | 256 | <p class=return> |
230 | Returns a string with the IP address of the peer, the | 257 | Returns a string with the IP address of the peer, the |
231 | port number that peer is using for the connection, | 258 | port number that peer is using for the connection, |
232 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 259 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
233 | In case of error, the method returns <b><tt>nil</tt></b>. | 260 | In case of error, the method returns <b><tt>nil</tt></b>. |
234 | </p> | 261 | </p> |
235 | 262 | ||
236 | <p class=note> | 263 | <p class=note> |
@@ -246,13 +273,13 @@ server:<b>getsockname()</b> | |||
246 | </p> | 273 | </p> |
247 | 274 | ||
248 | <p class=description> | 275 | <p class=description> |
249 | Returns the local address information associated to the object. | 276 | Returns the local address information associated to the object. |
250 | </p> | 277 | </p> |
251 | 278 | ||
252 | <p class=return> | 279 | <p class=return> |
253 | The method returns a string with local IP address, a number with | 280 | The method returns a string with local IP address, a number with |
254 | the local port, | 281 | the local port, |
255 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 282 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
256 | In case of error, the method returns <b><tt>nil</tt></b>. | 283 | In case of error, the method returns <b><tt>nil</tt></b>. |
257 | </p> | 284 | </p> |
258 | 285 | ||
@@ -266,32 +293,32 @@ server:<b>getstats()</b><br> | |||
266 | 293 | ||
267 | <p class=description> | 294 | <p class=description> |
268 | Returns accounting information on the socket, useful for throttling | 295 | Returns accounting information on the socket, useful for throttling |
269 | of bandwidth. | 296 | of bandwidth. |
270 | </p> | 297 | </p> |
271 | 298 | ||
272 | <p class=return> | 299 | <p class=return> |
273 | The method returns the number of bytes received, the number of bytes sent, | 300 | The method returns the number of bytes received, the number of bytes sent, |
274 | and the age of the socket object in seconds. | 301 | and the age of the socket object in seconds. |
275 | </p> | 302 | </p> |
276 | 303 | ||
277 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 304 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
278 | 305 | ||
279 | <p class=name id="listen"> | 306 | <p class=name id="listen"> |
280 | master:<b>listen(</b>backlog<b>)</b> | 307 | master:<b>listen(</b>backlog<b>)</b> |
281 | </p> | 308 | </p> |
282 | 309 | ||
283 | <p class=description> | 310 | <p class=description> |
284 | Specifies the socket is willing to receive connections, transforming the | 311 | Specifies the socket is willing to receive connections, transforming the |
285 | object into a server object. Server objects support the | 312 | object into a server object. Server objects support the |
286 | <a href=#accept><tt>accept</tt></a>, | 313 | <a href=#accept><tt>accept</tt></a>, |
287 | <a href=#getsockname><tt>getsockname</tt></a>, | 314 | <a href=#getsockname><tt>getsockname</tt></a>, |
288 | <a href=#setoption><tt>setoption</tt></a>, | 315 | <a href=#setoption><tt>setoption</tt></a>, |
289 | <a href=#settimeout><tt>settimeout</tt></a>, | 316 | <a href=#settimeout><tt>settimeout</tt></a>, |
290 | and <a href=#close><tt>close</tt></a> methods. | 317 | and <a href=#close><tt>close</tt></a> methods. |
291 | </p> | 318 | </p> |
292 | 319 | ||
293 | <p class=parameters> | 320 | <p class=parameters> |
294 | The parameter <tt>backlog</tt> specifies the number of client | 321 | The parameter <tt>backlog</tt> specifies the number of client |
295 | connections that can | 322 | connections that can |
296 | be queued waiting for service. If the queue is full and another client | 323 | be queued waiting for service. If the queue is full and another client |
297 | attempts connection, the connection is refused. | 324 | attempts connection, the connection is refused. |
@@ -310,11 +337,11 @@ client:<b>receive(</b>[pattern [, prefix]]<b>)</b> | |||
310 | 337 | ||
311 | <p class=description> | 338 | <p class=description> |
312 | Reads data from a client object, according to the specified <em>read | 339 | Reads data from a client object, according to the specified <em>read |
313 | pattern</em>. Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible. | 340 | pattern</em>. Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible. |
314 | </p> | 341 | </p> |
315 | 342 | ||
316 | <p class=parameters> | 343 | <p class=parameters> |
317 | <tt>Pattern</tt> can be any of the following: | 344 | <tt>Pattern</tt> can be any of the following: |
318 | </p> | 345 | </p> |
319 | 346 | ||
320 | <ul> | 347 | <ul> |
@@ -325,7 +352,7 @@ terminated by a LF character (ASCII 10), optionally preceded by a | |||
325 | CR character (ASCII 13). The CR and LF characters are not included in | 352 | CR character (ASCII 13). The CR and LF characters are not included in |
326 | the returned line. In fact, <em>all</em> CR characters are | 353 | the returned line. In fact, <em>all</em> CR characters are |
327 | ignored by the pattern. This is the default pattern; | 354 | ignored by the pattern. This is the default pattern; |
328 | <li> <tt>number</tt>: causes the method to read a specified <tt>number</tt> | 355 | <li> <tt>number</tt>: causes the method to read a specified <tt>number</tt> |
329 | of bytes from the socket. | 356 | of bytes from the socket. |
330 | </ul> | 357 | </ul> |
331 | 358 | ||
@@ -347,10 +374,10 @@ closed before the transmission was completed or the string | |||
347 | <p class=note> | 374 | <p class=note> |
348 | <b>Important note</b>: This function was changed <em>severely</em>. It used | 375 | <b>Important note</b>: This function was changed <em>severely</em>. It used |
349 | to support multiple patterns (but I have never seen this feature used) and | 376 | to support multiple patterns (but I have never seen this feature used) and |
350 | now it doesn't anymore. Partial results used to be returned in the same | 377 | now it doesn't anymore. Partial results used to be returned in the same |
351 | way as successful results. This last feature violated the idea that all | 378 | way as successful results. This last feature violated the idea that all |
352 | functions should return <tt><b>nil</b></tt> on error. Thus it was changed | 379 | functions should return <tt><b>nil</b></tt> on error. Thus it was changed |
353 | too. | 380 | too. |
354 | </p> | 381 | </p> |
355 | 382 | ||
356 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 383 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -366,7 +393,7 @@ Sends <tt>data</tt> through client object. | |||
366 | <p class=parameters> | 393 | <p class=parameters> |
367 | <tt>Data</tt> is the string to be sent. The optional arguments | 394 | <tt>Data</tt> is the string to be sent. The optional arguments |
368 | <tt>i</tt> and <tt>j</tt> work exactly like the standard | 395 | <tt>i</tt> and <tt>j</tt> work exactly like the standard |
369 | <tt>string.sub</tt> Lua function to allow the selection of a | 396 | <tt>string.sub</tt> Lua function to allow the selection of a |
370 | substring to be sent. | 397 | substring to be sent. |
371 | </p> | 398 | </p> |
372 | 399 | ||
@@ -385,10 +412,10 @@ there was a timeout during the operation. | |||
385 | </p> | 412 | </p> |
386 | 413 | ||
387 | <p class=note> | 414 | <p class=note> |
388 | Note: Output is <em>not</em> buffered. For small strings, | 415 | Note: Output is <em>not</em> buffered. For small strings, |
389 | it is always better to concatenate them in Lua | 416 | it is always better to concatenate them in Lua |
390 | (with the '<tt>..</tt>' operator) and send the result in one call | 417 | (with the '<tt>..</tt>' operator) and send the result in one call |
391 | instead of calling the method several times. | 418 | instead of calling the method several times. |
392 | </p> | 419 | </p> |
393 | 420 | ||
394 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 421 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -400,12 +427,12 @@ server:<b>setoption(</b>option [, value]<b>)</b> | |||
400 | 427 | ||
401 | <p class=description> | 428 | <p class=description> |
402 | Sets options for the TCP object. Options are only needed by low-level or | 429 | Sets options for the TCP object. Options are only needed by low-level or |
403 | time-critical applications. You should only modify an option if you | 430 | time-critical applications. You should only modify an option if you |
404 | are sure you need it. | 431 | are sure you need it. |
405 | </p> | 432 | </p> |
406 | 433 | ||
407 | <p class=parameters> | 434 | <p class=parameters> |
408 | <tt>Option</tt> is a string with the option name, and <tt>value</tt> | 435 | <tt>Option</tt> is a string with the option name, and <tt>value</tt> |
409 | depends on the option being set: | 436 | depends on the option being set: |
410 | 437 | ||
411 | <ul> | 438 | <ul> |
@@ -413,7 +440,7 @@ depends on the option being set: | |||
413 | <li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables | 440 | <li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables |
414 | the periodic transmission of messages on a connected socket. Should the | 441 | the periodic transmission of messages on a connected socket. Should the |
415 | connected party fail to respond to these messages, the connection is | 442 | connected party fail to respond to these messages, the connection is |
416 | considered broken and processes using the socket are notified; | 443 | considered broken and processes using the socket are notified; |
417 | 444 | ||
418 | <li> '<tt>linger</tt>': Controls the action taken when unsent data are | 445 | <li> '<tt>linger</tt>': Controls the action taken when unsent data are |
419 | queued on a socket and a close is performed. The value is a table with a | 446 | queued on a socket and a close is performed. The value is a table with a |
@@ -424,13 +451,13 @@ it is able to transmit the data or until '<tt>timeout</tt>' has passed. If | |||
424 | '<tt>on</tt>' is <tt>false</tt> and a close is issued, the system will | 451 | '<tt>on</tt>' is <tt>false</tt> and a close is issued, the system will |
425 | process the close in a manner that allows the process to continue as | 452 | process the close in a manner that allows the process to continue as |
426 | quickly as possible. I do not advise you to set this to anything other than | 453 | quickly as possible. I do not advise you to set this to anything other than |
427 | zero; | 454 | zero; |
428 | 455 | ||
429 | <li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules | 456 | <li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules |
430 | used in validating addresses supplied in a call to | 457 | used in validating addresses supplied in a call to |
431 | <a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; | 458 | <a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; |
432 | 459 | ||
433 | <li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> | 460 | <li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> |
434 | disables the Nagle's algorithm for the connection; | 461 | disables the Nagle's algorithm for the connection; |
435 | 462 | ||
436 | <li> '<tt>ipv6-v6only</tt>': | 463 | <li> '<tt>ipv6-v6only</tt>': |
@@ -485,7 +512,7 @@ server:<b>setstats(</b>received, sent, age<b>)</b><br> | |||
485 | 512 | ||
486 | <p class=description> | 513 | <p class=description> |
487 | Resets accounting information on the socket, useful for throttling | 514 | Resets accounting information on the socket, useful for throttling |
488 | of bandwidth. | 515 | of bandwidth. |
489 | </p> | 516 | </p> |
490 | 517 | ||
491 | <p class=parameters> | 518 | <p class=parameters> |
@@ -495,7 +522,7 @@ of bandwidth. | |||
495 | </p> | 522 | </p> |
496 | 523 | ||
497 | <p class=return> | 524 | <p class=return> |
498 | The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. | 525 | The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. |
499 | </p> | 526 | </p> |
500 | 527 | ||
501 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 528 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -509,8 +536,8 @@ server:<b>settimeout(</b>value [, mode]<b>)</b> | |||
509 | <p class=description> | 536 | <p class=description> |
510 | Changes the timeout values for the object. By default, | 537 | Changes the timeout values for the object. By default, |
511 | all I/O operations are blocking. That is, any call to the methods | 538 | all I/O operations are blocking. That is, any call to the methods |
512 | <a href=#send><tt>send</tt></a>, | 539 | <a href=#send><tt>send</tt></a>, |
513 | <a href=#receive><tt>receive</tt></a>, and | 540 | <a href=#receive><tt>receive</tt></a>, and |
514 | <a href=#accept><tt>accept</tt></a> | 541 | <a href=#accept><tt>accept</tt></a> |
515 | will block indefinitely, until the operation completes. The | 542 | will block indefinitely, until the operation completes. The |
516 | <tt>settimeout</tt> method defines a limit on the amount of time the | 543 | <tt>settimeout</tt> method defines a limit on the amount of time the |
@@ -521,7 +548,7 @@ time has elapsed, the affected methods give up and fail with an error code. | |||
521 | <p class=parameters> | 548 | <p class=parameters> |
522 | The amount of time to wait is specified as the | 549 | The amount of time to wait is specified as the |
523 | <tt>value</tt> parameter, in seconds. There are two timeout modes and | 550 | <tt>value</tt> parameter, in seconds. There are two timeout modes and |
524 | both can be used together for fine tuning: | 551 | both can be used together for fine tuning: |
525 | </p> | 552 | </p> |
526 | 553 | ||
527 | <ul> | 554 | <ul> |
@@ -532,7 +559,7 @@ default mode;</li> | |||
532 | 559 | ||
533 | <li> '<tt>t</tt>': <em>total</em> timeout. Specifies the upper limit on | 560 | <li> '<tt>t</tt>': <em>total</em> timeout. Specifies the upper limit on |
534 | the amount of time LuaSocket can block a Lua script before returning from | 561 | the amount of time LuaSocket can block a Lua script before returning from |
535 | a call.</li> | 562 | a call.</li> |
536 | </ul> | 563 | </ul> |
537 | 564 | ||
538 | <p class=parameters> | 565 | <p class=parameters> |
@@ -562,7 +589,7 @@ client:<b>shutdown(</b>mode<b>)</b><br> | |||
562 | </p> | 589 | </p> |
563 | 590 | ||
564 | <p class=description> | 591 | <p class=description> |
565 | Shuts down part of a full-duplex connection. | 592 | Shuts down part of a full-duplex connection. |
566 | </p> | 593 | </p> |
567 | 594 | ||
568 | <p class=parameters> | 595 | <p class=parameters> |
@@ -608,7 +635,7 @@ server:<b>getfd()</b> | |||
608 | </p> | 635 | </p> |
609 | 636 | ||
610 | <p class=description> | 637 | <p class=description> |
611 | Returns the underling socket descriptor or handle associated to the object. | 638 | Returns the underling socket descriptor or handle associated to the object. |
612 | </p> | 639 | </p> |
613 | 640 | ||
614 | <p class=return> | 641 | <p class=return> |