diff --git a/doc/index.html b/doc/index.html index b96385e..7394386 100644 --- a/doc/index.html +++ b/doc/index.html @@ -108,21 +108,41 @@ contains several examples, this user's manual and the test procedures.

-I am also providing a Windows binary for those that want to give +I am also providing PC Win32 binaries for those that want to give LuaSocket a quick try:

-luasocket-2.0.exe +luasocket-2.0-beta-win32.zip

-This binary has been compiled with the LUASOCKET_DEBUG -option, and should be able to run the automatic test procedures. +The quick and dirty way to use these binaries is to unpack everything into a +directory, say c:\luasocket (include all Lua files from the +LuaSocket distrbitution in the same directory too!). +Then set LUA_INIT to load the lua.lua helper file:

+
+c:\luasocket\> set LUA_INIT=@lua.lua
+
+ +

+From that directory, you can then run the interpreter and it should find all +files it needs. To download this manual page from the Internet, for example, +do the following: +

+ +
+c:\luasocket\> lua
+Lua 5.0.2  Copyright (C) 1994-2004 Tecgraf, PUC-Rio
+> http = require"http"
+> print(http.request"http://www.tecgraf.puc-rio.br/luasocket/")
+--> this file
+
+

Special thanks

diff --git a/doc/reference.html b/doc/reference.html index f130d7b..ec81d72 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -140,6 +140,7 @@
DEBUG, dns, +newtry, protect, select, sink, diff --git a/doc/socket.html b/doc/socket.html index 06296a3..4d77478 100644 --- a/doc/socket.html +++ b/doc/socket.html @@ -60,6 +60,49 @@ This constant is set to true if the library was compiled with debug support.

+ + +

+socket.newtry(finalizer) +

+ +

+Creates and returns a clean +try +function that allows for cleanup before the exception +is raised. +

+ +

+Finalizer is a function that will be called before +try throws the exception. It will be called +in protected mode. +

+ +

+The function returns your customized try function. +

+ +

+Note: This idea saved a lot of work with the +implementation of protocols in LuaSocket: +

+ +
+foo = socket.protect(function()
+    -- connect somewhere
+    local c = socket.try(socket.connect("somewhere", 42))
+    -- create a try function that closes 'c' on error
+    local try = socket.newtry(function() c:close() end)
+    -- do everything reassured c will be closed 
+    try(c:send("helo there?\r\n"))
+    local answer = try(c:receive())
+    ...
+    try(c:send("good bye\r\n"))
+    c:close()
+end)
+
+ @@ -209,7 +252,7 @@ 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. +The function truncates time down to the nearest integer.

@@ -252,7 +295,8 @@ socket.time()

Returns the time in seconds, relative to the origin of the -universe. Only time differences are meaninful. +universe. You should subtract the values returned by this function +to get meaningful values.