diff options
Diffstat (limited to 'doc/tcp.html')
| -rw-r--r-- | doc/tcp.html | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/doc/tcp.html b/doc/tcp.html index 5f520e9..30e06f4 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
| @@ -260,7 +260,7 @@ method returns <b><tt>nil</tt></b> followed by an error message. | |||
| 260 | <!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 260 | <!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 261 | 261 | ||
| 262 | <p class=name id=receive> | 262 | <p class=name id=receive> |
| 263 | client:<b>receive(</b>[pattern]<b>)</b> | 263 | client:<b>receive(</b>[pattern [, prefix]]<b>)</b> |
| 264 | </p> | 264 | </p> |
| 265 | 265 | ||
| 266 | <p class=description> | 266 | <p class=description> |
| @@ -283,6 +283,11 @@ the returned line. This is the default pattern; | |||
| 283 | of bytes from the socket. | 283 | of bytes from the socket. |
| 284 | </ul> | 284 | </ul> |
| 285 | 285 | ||
| 286 | <p class=parameters> | ||
| 287 | <tt>Prefix</tt> is an optional string to be concatenated to the beginning | ||
| 288 | of any received data before return. | ||
| 289 | </p> | ||
| 290 | |||
| 286 | <p class=return> | 291 | <p class=return> |
| 287 | If successful, the method returns the received pattern. In case of error, | 292 | If successful, the method returns the received pattern. In case of error, |
| 288 | the method returns <tt><b>nil</b></tt> followed by an error message which | 293 | the method returns <tt><b>nil</b></tt> followed by an error message which |
| @@ -305,18 +310,18 @@ too. | |||
| 305 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 310 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 306 | 311 | ||
| 307 | <p class=name id=send> | 312 | <p class=name id=send> |
| 308 | client:<b>send(</b>string<sub>1</sub> [, | 313 | client:<b>send(</b>data [, i [, j]]<b>)</b> |
| 309 | string<sub>2</sub>, ... string<sub>N</sub>]<b>)</b> | ||
| 310 | </p> | 314 | </p> |
| 311 | 315 | ||
| 312 | <p class=description> | 316 | <p class=description> |
| 313 | Sends data through client object. | 317 | Sends <tt>data</tt> through client object. |
| 314 | </p> | 318 | </p> |
| 315 | 319 | ||
| 316 | <p class=parameters> | 320 | <p class=parameters> |
| 317 | All parameters should be strings. For small strings, it is always better to | 321 | <tt>Data</tt> is the string to be sent. The optional arguments |
| 318 | concatenate them in Lua (with the '<tt>..</tt>' operator) and pass the | 322 | <tt>i</tt> and <tt>j</tt> work exactly like the standard |
| 319 | result to LuaSocket instead of passing several independent strings. | 323 | <tt>string.sub</tt> Lua function to allow the selection of a |
| 324 | substring to be sent. | ||
| 320 | </p> | 325 | </p> |
| 321 | 326 | ||
| 322 | <p class=return> | 327 | <p class=return> |
| @@ -341,6 +346,22 @@ Alas, it wasn't returning <tt><b>nil</b></tt> in case of | |||
| 341 | error. So it was changed again in beta. | 346 | error. So it was changed again in beta. |
| 342 | </p> | 347 | </p> |
| 343 | 348 | ||
| 349 | <p class=note> | ||
| 350 | <b>Also important</b>: | ||
| 351 | In order to better support non-blocking I/O and to discourage | ||
| 352 | bad practice, the <tt>send</tt> method now only sends one string | ||
| 353 | per call. The other optional arguments allow the user to select | ||
| 354 | a substring to be sent in a much more efficient way than | ||
| 355 | using <tt>string.sub</tt>. | ||
| 356 | </p> | ||
| 357 | |||
| 358 | <p class=note> | ||
| 359 | Note: Output is <em>not</em> buffered. For small strings, | ||
| 360 | it is always better to concatenate them in Lua | ||
| 361 | (with the '<tt>..</tt>' operator) and send the result in one call | ||
| 362 | instead of calling the method several times. | ||
| 363 | </p> | ||
| 364 | |||
| 344 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 365 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 345 | 366 | ||
| 346 | <p class=name id=setoption> | 367 | <p class=name id=setoption> |
