From ac4aac0909da26befaaeb6b415f66cf35b6980e0 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Fri, 18 Jun 2004 08:02:09 +0000 Subject: Implemented safe exceptions. This looks preeety good. --- doc/reference.html | 3 ++- doc/socket.html | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++- doc/tcp.html | 28 ++++++++++++++--------- 3 files changed, 84 insertions(+), 13 deletions(-) (limited to 'doc') diff --git a/doc/reference.html b/doc/reference.html index 607958b..f130d7b 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -143,8 +143,9 @@ protect, select, sink, -source, +skip, sleep, +source, time, tcp, try, diff --git a/doc/socket.html b/doc/socket.html index d7739f8..06296a3 100644 --- a/doc/socket.html +++ b/doc/socket.html @@ -169,6 +169,49 @@ socket, leaving it open when done. The function returns a sink with the appropriate behavior.

+ + +

+socket.skip(d [, ret1, ret2 ... retN]) +

+ +

+Drops a number of arguments and returns the remaining. +

+ +

+D is the number of arguments to drop. Ret1 to +retN are the arguments. +

+ +

+The function returns retd+1 to retN. +

+ +

+Note: This function is useful to avoid creation of dummy variables: +

+ +
+-- get the status code and separator from SMTP server reply 
+local code, sep = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"))
+
+ + + +

+socket.sleep(time) +

+ +

+Freezes the program execution during a given amount of time. +

+ +

+Time is the number of seconds to sleep for. +The function truncates time to the nearest integer. +

+

@@ -201,6 +244,27 @@ side closes the connection. The function returns a source with the appropriate behavior.

+ + +

+socket.time() +

+ +

+Returns the time in seconds, relative to the origin of the +universe. Only time differences are meaninful. +

+ +

+The function returns the time as a number. +

+ +
+t = socket.time()
+-- do stuff
+print(socket.time() - t .. " seconds elapsed")
+
+

@@ -212,7 +276,7 @@ Throws an exception in case of error.

-Ret1 to retN can be arbitrary +Ret1 to retN can be arbitrary arguments, but are usually the return values of a function call nested with try.

diff --git a/doc/tcp.html b/doc/tcp.html index 781ec6f..cd417a5 100644 --- a/doc/tcp.html +++ b/doc/tcp.html @@ -277,9 +277,10 @@ the transmission.

Important note: This function was changed severely. It used to support multiple patterns (but I have never seen this feature used) and -partial results used to be returned in the same way as successful results. -This last feature violated the idea that all functions should return -nil on error. Thus the change. +now it doesn't anymore. Partial results used to be returned in the same +way as successful results. This last feature violated the idea that all +functions should return nil on error. Thus it was changed +too.

@@ -300,20 +301,25 @@ result to LuaSocket instead of passing several independent strings.

-The method returns the number of bytes accepted by the transport layer, -followed by an error code. The error code is nil if the operation -completed with no errors, the string 'closed' in case +If successful, the method returns the number of bytes accepted by +the transport layer. In case of error, the method returns +nil, followed by an error message, followed by the +partial number of bytes accepted by the transport layer. +The error message can be 'closed' in case the connection was closed before the transmission was completed or the string 'timeout' in case there was a timeout during the operation.

-Note: The return values for the send method have been changed in -LuaSocket 2.0! In previous versions, the method returned only the -error message. Since returning nil in case of success goes -against all other LuaSocket methods and functions, the -send method been changed for the sake of uniformity. +Important note: +The return values for the send method have been changed in +LuaSocket 2.0 alpha and again in the beta (sorry)! +In previous versions, the method returned only the +error message. Since returning nil in case of success was +nonsense, in alpha the first return value became the number of bytes sent. +Alas, it wasn't returning nil in case of +error. So it was changed again in beta.

-- cgit v1.2.3-55-g6feb