From 8d4e240f6ae50d9b22ddc44f5e207018935da907 Mon Sep 17 00:00:00 2001
From: Diego Nehab
@@ -150,7 +150,7 @@ error.
@@ -206,7 +206,7 @@ Here are a few examples with the simple interface:
@@ -239,7 +239,7 @@ and
-- loads the FTP module and any libraries it requires
-local ftp = require("ftp")
+local ftp = require("socket.ftp")
-- load the ftp support
-local ftp = require("ftp")
+local ftp = require("socket.ftp")
-- Log as user "anonymous" on server "ftp.tecgraf.puc-rio.br",
-- and get file "lua.tar.gz" from directory "pub/lua" as binary.
@@ -159,9 +159,9 @@ f, e = ftp.get("ftp://ftp.tecgraf.puc-rio.br/pub/lua/lua.tar.gz;type=i")
-- load needed modules
-local ftp = require("ftp")
+local ftp = require("socket.ftp")
local ltn12 = require("ltn12")
-local url = require("url")
+local url = require("socket.url")
-- a function that returns a directory listing
function nlst(u)
@@ -230,7 +230,7 @@ message describing the reason for failure.
-- load the ftp support
-local ftp = require("ftp")
+local ftp = require("socket.ftp")
-- Log as user "fulano" on server "ftp.example.com",
-- using password "silva", and store a file "README" with contents
@@ -241,7 +241,7 @@ f, e = ftp.put("ftp://fulano:silva@ftp.example.com/README",
-- load the ftp support
-local ftp = require("ftp")
+local ftp = require("socket.ftp")
local ltn12 = require("ltn12")
-- Log as user "fulano" on server "ftp.example.com",
diff --git a/doc/http.html b/doc/http.html
index 4cbbe95..af58571 100644
--- a/doc/http.html
+++ b/doc/http.html
@@ -62,7 +62,7 @@ To obtain the http namespace, run:
-- loads the HTTP module and any libraries it requires
-local http = require("http")
+local http = require("socket.http")
-- load the http module
-http = require("http")
+http = require("socket.http")
-- connect to server "www.tecgraf.puc-rio.br" and retrieves this manual
-- file from "/luasocket/http.html"
@@ -231,7 +231,7 @@ And here is an example using the generic interface:
-- load the http module
-http = require("http")
+http = require("socket.http")
-- Requests information about a document, without downloading it.
-- Useful, for example, if you want to display a download gauge and need
@@ -276,7 +276,7 @@ authentication is required.
-- load required modules
-http = require("http")
+http = require("socket.http")
mime = require("mime")
-- Connect to server "www.example.com" and tries to retrieve
diff --git a/doc/introduction.html b/doc/introduction.html
index f8fe078..c88fa40 100644
--- a/doc/introduction.html
+++ b/doc/introduction.html
@@ -182,7 +182,7 @@ program.
-- load namespace
local socket = require("socket")
-- create a TCP socket and bind it to the local host, at any port
-local server = socket.try(socket.bind("*", 0))
+local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
@@ -287,13 +287,13 @@ local host, port = "localhost", 13
-- load namespace
local socket = require("socket")
-- convert host name to ip address
-local ip = socket.try(socket.dns.toip(host))
+local ip = assert(socket.dns.toip(host))
-- create a new UDP object
-local udp = socket.try(socket.udp())
+local udp = assert(socket.udp())
-- contact daytime host
-socket.try(udp:sendto("anything", ip, port))
+assert(udp:sendto("anything", ip, port))
-- retrieve the answer and print results
-io.write(socket.try((udp:receive())))
+io.write(assert(udp:receive()))
diff --git a/doc/ltn12.html b/doc/ltn12.html
index 44fcbe4..c5a0f59 100644
--- a/doc/ltn12.html
+++ b/doc/ltn12.html
@@ -271,7 +271,7 @@ The function returns the sink and the table used to store the chunks.
-- load needed modules
-local http = require("http")
+local http = require("socket.http")
local ltn12 = require("ltn12")
-- a simplified http.get function
diff --git a/doc/smtp.html b/doc/smtp.html
index 8feae3e..bd18bfa 100644
--- a/doc/smtp.html
+++ b/doc/smtp.html
@@ -69,7 +69,7 @@ To obtain the smtp namespace, run:
-- loads the SMTP module and everything it requires
-local smtp = require("smtp")
+local smtp = require("socket.smtp")
-- load the smtp support
-local smtp = require("smtp")
+local smtp = require("socket.smtp")
-- Connects to server "localhost" and sends a message to users
-- "fulano@example.com", "beltrano@example.com",
@@ -329,7 +329,7 @@ as listed in the introduction.
-- load the smtp support and its friends
-local smtp = require("smtp")
+local smtp = require("socket.smtp")
local mime = require("mime")
local ltn12 = require("ltn12")
diff --git a/doc/socket.html b/doc/socket.html
index f638fd9..18c71d1 100644
--- a/doc/socket.html
+++ b/doc/socket.html
@@ -145,7 +145,10 @@ socket.protect(func)
-Converts a function that throws exceptions into a safe function.
+Converts a function that throws exceptions into a safe function. This
+function only catches exceptions thrown by the try
+and newtry functions. It does not catch normal
+Lua errors.
@@ -346,7 +349,9 @@ socket.try(ret1 [, ret2 ... retN])
-Throws an exception in case of error.
+Throws an exception in case of error. The exception can only be caught
+by the protect function. It does not explode
+into an error message.
diff --git a/doc/url.html b/doc/url.html
index 56e1ef5..ac84d24 100644
--- a/doc/url.html
+++ b/doc/url.html
@@ -52,7 +52,7 @@ To obtain the url namespace, run:
-- loads the URL module
-local url = require("url")
+local url = require("socket.url")
@@ -193,7 +193,7 @@ The function returns the encoded string.
-- load url module
-url = require("url")
+url = require("socket.url")
code = url.escape("/#?;")
-- code = "%2f%23%3f%3b"
@@ -239,7 +239,7 @@ parsed_url = {
-- load url module
-url = require("url")
+url = require("socket.url")
parsed_url = url.parse("http://www.example.com/cgilua/index.lua?a=2#there")
-- parsed_url = {
--
cgit v1.2.3-55-g6feb