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/socket.html | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'doc/socket.html') 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.

-- cgit v1.2.3-55-g6feb