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/tcp.html | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'doc/tcp.html') 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