Fixing bugs...
This commit is contained in:
parent
5dc5c3ebe8
commit
f7579db9e8
24 changed files with 127 additions and 94 deletions
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
|
18
doc/ftp.html
18
doc/ftp.html
|
@ -14,7 +14,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -227,10 +227,10 @@ message describing the reason for failure.
|
|||
-- load the ftp support
|
||||
local ftp = require("ftp")
|
||||
|
||||
-- Log as user "diego" on server "ftp.tecgraf.puc-rio.br",
|
||||
-- using password "nehab", and store a file "README" with contents
|
||||
-- Log as user "fulano" on server "ftp.example.com",
|
||||
-- using password "silva", and store a file "README" with contents
|
||||
-- "wrong password, of course"
|
||||
f, e = ftp.put("ftp://diego:nehab@ftp.tecgraf.puc-rio.br/README",
|
||||
f, e = ftp.put("ftp://fulano:silva@ftp.example.com/README",
|
||||
"wrong password, of course")
|
||||
</pre>
|
||||
|
||||
|
@ -239,13 +239,13 @@ f, e = ftp.put("ftp://diego:nehab@ftp.tecgraf.puc-rio.br/README",
|
|||
local ftp = require("ftp")
|
||||
local ltn12 = require("ltn12")
|
||||
|
||||
-- Log as user "diego" on server "ftp.tecgraf.puc-rio.br",
|
||||
-- using password "nehab", and append to the remote file "LOG", sending the
|
||||
-- Log as user "fulano" on server "ftp.example.com",
|
||||
-- using password "silva", and append to the remote file "LOG", sending the
|
||||
-- contents of the local file "LOCAL-LOG"
|
||||
f, e = ftp.put{
|
||||
host = "ftp.tecgraf.puc-rio.br",
|
||||
user = "diego",
|
||||
password = "nehab",
|
||||
host = "ftp.example.com",
|
||||
user = "fulano",
|
||||
password = "silva",
|
||||
command = "appe",
|
||||
argument = "LOG",
|
||||
source = ltn12.source.file(io.open("LOCAL-LOG", "r"))
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -209,9 +209,9 @@ http = require("http")
|
|||
-- file from "/luasocket/http.html"
|
||||
b = http.request("http://www.tecgraf.puc-rio.br/luasocket/http.html")
|
||||
|
||||
-- connect to server "www.tecgraf.puc-rio.br" and tries to retrieve
|
||||
-- "~diego/auth/index.html". Fails because authentication is needed.
|
||||
b, c, h = http.request("http://www.tecgraf.puc-rio.br/~diego/auth/index.html")
|
||||
-- connect to server "www.example.com" and tries to retrieve
|
||||
-- "/private/index.html". Fails because authentication is needed.
|
||||
b, c, h = http.request("http://www.example.com/private/index.html")
|
||||
-- b returns some useless page telling about the denied access,
|
||||
-- h returns authentication information
|
||||
-- and c returns with value 401 (Authentication Required)
|
||||
|
@ -276,16 +276,16 @@ authentication is required.
|
|||
http = require("http")
|
||||
mime = require("mime")
|
||||
|
||||
-- Connect to server "www.tecgraf.puc-rio.br" and tries to retrieve
|
||||
-- "~diego/auth/index.html", using the provided name and password to
|
||||
-- Connect to server "www.example.com" and tries to retrieve
|
||||
-- "/private/index.html", using the provided name and password to
|
||||
-- authenticate the request
|
||||
b, c, h = http.request("http://diego:password@www.tecgraf.puc-rio.br/~diego/auth/index.html")
|
||||
b, c, h = http.request("http://fulano:silva@www.example.com/private/index.html")
|
||||
|
||||
-- Alternatively, one could fill the appropriate header and authenticate
|
||||
-- the request directly.
|
||||
r, c = http.request {
|
||||
url = "http://www.tecgraf.puc-rio.br/~diego/auth/index.html",
|
||||
headers = { authentication = "Basic " .. (mime.b64("diego:password")) }
|
||||
url = "http://www.example.com/private/index.html",
|
||||
headers = { authentication = "Basic " .. (mime.b64("fulano:silva")) }
|
||||
}
|
||||
</pre>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -216,7 +216,7 @@ the changes that made it into version 2.0:
|
|||
|
||||
<li> Select checks if sockets have buffered data and returns immediately;
|
||||
|
||||
<li> <tt>socket.sleep</tt> and <tt>socket.time</tt> are now part of the
|
||||
<li> <tt>socket.sleep</tt> and <tt>socket.gettime</tt> are now part of the
|
||||
library and are supported. They used to be available only when
|
||||
LUASOCKET_DEBUG was defined, but it turns out they might be useful for
|
||||
applications;
|
||||
|
@ -276,6 +276,8 @@ return convention WILL break old code;
|
|||
does not call <tt>listen</tt> anymore. It is the new <tt>listen</tt>
|
||||
method that turns a TCP object into a server object;
|
||||
|
||||
<li> <tt>socket.time</tt> became <tt>socket.gettime</tt> for uniformity;
|
||||
|
||||
<li> Interface to options has changed.
|
||||
|
||||
</ul>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
body {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
font-family: "Verdana";
|
||||
font-family: "Verdana", sans-serif;
|
||||
}
|
||||
|
||||
tt {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -140,6 +140,7 @@
|
|||
<blockquote>
|
||||
<a href="socket.html#debug">DEBUG</a>,
|
||||
<a href="dns.html#dns">dns</a>,
|
||||
<a href="socket.html#gettime">gettime</a>,
|
||||
<a href="socket.html#newtry">newtry</a>,
|
||||
<a href="socket.html#protect">protect</a>,
|
||||
<a href="socket.html#select">select</a>,
|
||||
|
@ -147,7 +148,6 @@
|
|||
<a href="socket.html#skip">skip</a>,
|
||||
<a href="socket.html#sleep">sleep</a>,
|
||||
<a href="socket.html#source">source</a>,
|
||||
<a href="socket.html#time">time</a>,
|
||||
<a href="tcp.html#tcp">tcp</a>,
|
||||
<a href="socket.html#try">try</a>,
|
||||
<a href="udp.html#udp">udp</a>,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -165,7 +165,7 @@ If successful, the function returns 1. Otherwise, the function returns
|
|||
<p class=note>
|
||||
Note: SMTP servers are can be very picky with the format of e-mail
|
||||
addresses. To be safe, use only addresses of the form
|
||||
"<tt><fulano@tecgraf.puc-rio.br></tt>" in the <tt>from</tt> and
|
||||
"<tt><fulano@example.com></tt>" in the <tt>from</tt> and
|
||||
<tt>rcpt</tt> arguments to the <tt>send</tt> function. In headers, e-mail
|
||||
addresses can take whatever form you like. </p>
|
||||
|
||||
|
@ -238,23 +238,23 @@ and
|
|||
local smtp = require("smtp")
|
||||
|
||||
-- Connects to server "localhost" and sends a message to users
|
||||
-- "fulano@tecgraf.puc-rio.br", "beltrano@tecgraf.puc-rio.br",
|
||||
-- and "sicrano@tecgraf.puc-rio.br".
|
||||
-- "fulano@example.com", "beltrano@example.com",
|
||||
-- and "sicrano@example.com".
|
||||
-- Note that "fulano" is the primary recipient, "beltrano" receives a
|
||||
-- carbon copy and neither of them knows that "sicrano" received a blind
|
||||
-- carbon copy of the message.
|
||||
from = "<luasocket@tecgraf.puc-rio.br>"
|
||||
from = "<luasocket@example.com>"
|
||||
|
||||
rcpt = {
|
||||
"<fulano@tecgraf.puc-rio.br>",
|
||||
"<beltrano@tecgraf.puc-rio.br>",
|
||||
"<sicrano@tecgraf.puc-rio.br>"
|
||||
"<fulano@example.com>",
|
||||
"<beltrano@example.com>",
|
||||
"<sicrano@example.com>"
|
||||
}
|
||||
|
||||
mesgt = {
|
||||
headers = {
|
||||
to = "Fulano da Silva <fulano@tecgraf.puc-rio.br>",
|
||||
cc = '"Beltrano F. Nunes" <beltrano@tecgraf.puc-rio.br>',
|
||||
to = "Fulano da Silva <fulano@example.com>",
|
||||
cc = '"Beltrano F. Nunes" <beltrano@example.com>',
|
||||
subject = "My first message"
|
||||
}
|
||||
body = "I hope this works. If it does, I can send you another 1000 copies."
|
||||
|
@ -334,8 +334,8 @@ local ltn12 = require("ltn12")
|
|||
source = smtp.message{
|
||||
headers = {
|
||||
-- Remember that headers are *ignored* by smtp.send.
|
||||
from = "Sicrano de Oliveira <sicrano@tecgraf.puc-rio.br>",
|
||||
to = "Fulano da Silva <fulano@tecgraf.puc-rio.br>",
|
||||
from = "Sicrano de Oliveira <sicrano@example.com>",
|
||||
to = "Fulano da Silva <fulano@example.com>",
|
||||
subject = "Here is a message with attachments"
|
||||
},
|
||||
body = {
|
||||
|
@ -378,8 +378,8 @@ source = smtp.message{
|
|||
|
||||
-- finally send it
|
||||
r, e = smtp.send{
|
||||
from = "<sicrano@tecgraf.puc-rio.br>",
|
||||
rcpt = "<fulano@tecgraf.puc-rio.br>",
|
||||
from = "<sicrano@example.com>",
|
||||
rcpt = "<fulano@example.com>",
|
||||
source = source,
|
||||
}
|
||||
</pre>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -48,6 +48,27 @@ To obtain the <tt>socket</tt> namespace, run:
|
|||
local socket = require("socket")
|
||||
</pre>
|
||||
|
||||
<!-- bind ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<p class=name id=bind>
|
||||
socket.<b>bind(</b>address, port [, backlog]<b>)</b>
|
||||
</p>
|
||||
|
||||
<p class=description>
|
||||
</p>
|
||||
|
||||
<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<p class=name id=connect>
|
||||
socket.<b>connect(</b>address, port [, locaddr, locport]<b>)</b>
|
||||
</p>
|
||||
|
||||
<p class=description>
|
||||
This function is a shortcut that creates and returns a TCP socket object
|
||||
connected to a remote <tt>host</tt> at a given <tt>port</tt>. Optionally,
|
||||
the use can also specify the local address and port to bind
|
||||
(<tt>locaddr</tt> and </tt>locport</tt>).
|
||||
</p>
|
||||
|
||||
<!-- debug ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
|
@ -289,8 +310,8 @@ The function returns a source with the appropriate behavior.
|
|||
|
||||
<!-- time ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<p class=name id=time>
|
||||
socket.<b>time()</b>
|
||||
<p class=name id=gettime>
|
||||
socket.<b>gettime()</b>
|
||||
</p>
|
||||
|
||||
<p class=description>
|
||||
|
@ -304,9 +325,9 @@ The function returns the time as a number.
|
|||
</p>
|
||||
|
||||
<pre class=example>
|
||||
t = socket.time()
|
||||
t = socket.gettime()
|
||||
-- do stuff
|
||||
print(socket.time() - t .. " seconds elapsed")
|
||||
print(socket.gettime() - t .. " seconds elapsed")
|
||||
</pre>
|
||||
|
||||
<!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -74,7 +74,7 @@ reported by <b><tt>nil</tt></b> followed by a message describing the error.
|
|||
</p>
|
||||
|
||||
<p class=note>
|
||||
Note: calling <a href=misc.html#socket.select><tt>socket.select</tt></a>
|
||||
Note: calling <a href=sockett.html#select><tt>socket.select</tt></a>
|
||||
with a server object in
|
||||
the <tt>receive</tt> parameter before a call to <tt>accept</tt> does
|
||||
<em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a
|
||||
|
@ -94,7 +94,7 @@ local host.
|
|||
|
||||
<p class=parameters>
|
||||
<tt>Address</tt> can be an IP address or a host name.
|
||||
<tt>Port</tt> must be an integer number in the range [0..64K].
|
||||
<tt>Port</tt> must be an integer number in the range [0..64K).
|
||||
If <tt>address</tt>
|
||||
is '<tt>*</tt>', the system binds to all local interfaces
|
||||
using the <tt>INADDR_ANY</tt> constant. If <tt>port</tt> is 0, the system automatically
|
||||
|
@ -154,7 +154,7 @@ and <a href=#close><tt>close</tt></a>.
|
|||
|
||||
<p class=parameters>
|
||||
<tt>Address</tt> can be an IP address or a host name.
|
||||
<tt>Port</tt> must be an integer number in the range [1..64K].
|
||||
<tt>Port</tt> must be an integer number in the range [1..64K).
|
||||
</p>
|
||||
|
||||
<p class=return>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<center>
|
||||
<table summary="LuaSocket logo">
|
||||
<tr><td align=center><a href="http://www.lua.org">
|
||||
<img border=0 alt="LuaSocket" src="luasocket.png">
|
||||
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
|
||||
</a></td></tr>
|
||||
<tr><td align=center valign=top>Network support for the Lua language
|
||||
</td></tr>
|
||||
|
@ -238,11 +238,11 @@ parsed_url = {<br>
|
|||
-- load url module
|
||||
url = require("url")
|
||||
|
||||
parsed_url = url.parse("http://www.puc-rio.br/~diego/index.lua?a=2#there")
|
||||
parsed_url = url.parse("http://www.example.com/cgilua/index.lua?a=2#there")
|
||||
-- parsed_url = {
|
||||
-- scheme = "http",
|
||||
-- authority = "www.puc-rio.br",
|
||||
-- path = "/~diego/index.lua"
|
||||
-- authority = "www.example.com",
|
||||
-- path = "/cgilua/index.lua"
|
||||
-- query = "a=2",
|
||||
-- fragment = "there",
|
||||
-- host = "www.puc-rio.br",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue