Forward server working on Mac OS X...

This commit is contained in:
Diego Nehab
2005-02-08 10:01:01 +00:00
parent 5d32848674
commit 8d4e240f6a
29 changed files with 800 additions and 101 deletions

View File

@ -65,7 +65,7 @@ To obtain the <tt>ftp</tt> namespace, run:
<pre class=example>
-- loads the FTP module and any libraries it requires
local ftp = require("ftp")
local ftp = require("socket.ftp")
</pre>
<p>
@ -150,7 +150,7 @@ error.
<pre class=example>
-- 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")
<pre class=example>
-- 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.
<pre class=example>
-- 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",
<pre class=example>
-- 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",

View File

@ -62,7 +62,7 @@ To obtain the <tt>http</tt> namespace, run:
<pre class=example>
-- loads the HTTP module and any libraries it requires
local http = require("http")
local http = require("socket.http")
</pre>
<p>
@ -206,7 +206,7 @@ Here are a few examples with the simple interface:
<pre class=example>
-- 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:
<pre class=example>
-- 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.
<pre class=example>
-- load required modules
http = require("http")
http = require("socket.http")
mime = require("mime")
-- Connect to server "www.example.com" and tries to retrieve

View File

@ -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()))
</pre>
</blockquote>

View File

@ -271,7 +271,7 @@ The function returns the sink and the table used to store the chunks.
<pre class=example>
-- load needed modules
local http = require("http")
local http = require("socket.http")
local ltn12 = require("ltn12")
-- a simplified http.get function

View File

@ -69,7 +69,7 @@ To obtain the <tt>smtp</tt> namespace, run:
<pre class=example>
-- loads the SMTP module and everything it requires
local smtp = require("smtp")
local smtp = require("socket.smtp")
</pre>
<p>
@ -239,7 +239,7 @@ and
<pre class=example>
-- 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. </p>
<pre class=example>
-- load the smtp support and its friends
local smtp = require("smtp")
local smtp = require("socket.smtp")
local mime = require("mime")
local ltn12 = require("ltn12")

View File

@ -145,7 +145,10 @@ socket.<b>protect(</b>func<b>)</b>
</p>
<p class=description>
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 <a href=#try><tt>try</tt></a>
and <a href=#newtry><tt>newtry</tt></a> functions. It does not catch normal
Lua errors.
</p>
<p class=parameters>
@ -346,7 +349,9 @@ socket.<b>try(</b>ret<sub>1</sub> [, ret<sub>2</sub> ... ret<sub>N</sub>]<b>)</b
</p>
<p class=description>
Throws an exception in case of error.
Throws an exception in case of error. The exception can only be caught
by the <a href=#protect><tt>protect</tt></a> function. It does not explode
into an error message.
</p>
<p class=parameters>

View File

@ -52,7 +52,7 @@ To obtain the <tt>url</tt> namespace, run:
<pre class=example>
-- loads the URL module
local url = require("url")
local url = require("socket.url")
</pre>
<p>
@ -193,7 +193,7 @@ The function returns the encoded string.
<pre class=example>
-- load url module
url = require("url")
url = require("socket.url")
code = url.escape("/#?;")
-- code = "%2f%23%3f%3b"
@ -239,7 +239,7 @@ parsed_url = {<br>
<pre class=example>
-- 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 = {