From c8b402e00442cd249397d4d33d2723a1f08a8108 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Sun, 18 Jul 2004 22:56:14 +0000 Subject: Changed send function. --- doc/introduction.html | 2 +- doc/tcp.html | 35 ++++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'doc') diff --git a/doc/introduction.html b/doc/introduction.html index 6468148..20c4d36 100644 --- a/doc/introduction.html +++ b/doc/introduction.html @@ -113,7 +113,7 @@ The core LuaSocket is almost entirely implemented in C. It is usually available as a dynamic library which the interpreter can load with the help of a loader module written in Lua. Beginning with version 2.0 and following the Lua 5.0 trend, all LuaSocket -functionality is defined inside tables (or rather a namespaces). No global +functionality is defined inside tables (or rather namespaces). No global variables are ever created. Namespaces are obtained with the require Lua function, which loads and initializes any required library and returns the namespace. 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 nil followed by an error message.

-client:receive([pattern]) +client:receive([pattern [, prefix]])

@@ -283,6 +283,11 @@ the returned line. This is the default pattern; of bytes from the socket. +

+Prefix is an optional string to be concatenated to the beginning +of any received data before return. +

+

If successful, the method returns the received pattern. In case of error, the method returns nil followed by an error message which @@ -305,18 +310,18 @@ too.

-client:send(string1 [, -string2, ... stringN]) +client:send(data [, i [, j]])

-Sends data through client object. +Sends data through client object.

-All parameters should be strings. For small strings, it is always better to -concatenate them in Lua (with the '..' operator) and pass the -result to LuaSocket instead of passing several independent strings. +Data is the string to be sent. The optional arguments +i and j work exactly like the standard +string.sub Lua function to allow the selection of a +substring to be sent.

@@ -341,6 +346,22 @@ Alas, it wasn't returning nil in case of error. So it was changed again in beta.

+

+Also important: +In order to better support non-blocking I/O and to discourage +bad practice, the send method now only sends one string +per call. The other optional arguments allow the user to select +a substring to be sent in a much more efficient way than +using string.sub. +

+ +

+Note: Output is not buffered. For small strings, +it is always better to concatenate them in Lua +(with the '..' operator) and send the result in one call +instead of calling the method several times. +

+

-- cgit v1.2.3-55-g6feb