mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 14:28:21 +01:00
Almost ready to release beta3
This commit is contained in:
parent
a8254e94f8
commit
97b26e0b66
@ -1,11 +1,6 @@
|
|||||||
This directory contains code that is more useful than the examples. This code
|
This directory contains code that is more useful than the examples. This code
|
||||||
*is* supported.
|
*is* supported.
|
||||||
|
|
||||||
lua.lua -- new require and requirelib implementations
|
|
||||||
|
|
||||||
This is to support dynamic loading of LuaSocket. Check the INSTALL
|
|
||||||
file for more information.
|
|
||||||
|
|
||||||
tftp.lua -- Trivial FTP client
|
tftp.lua -- Trivial FTP client
|
||||||
|
|
||||||
This module implements file retrieval by the TFTP protocol. Its main use
|
This module implements file retrieval by the TFTP protocol. Its main use
|
||||||
|
@ -151,4 +151,4 @@ get = socket.protect(function(gett)
|
|||||||
else return tget(gett) end
|
else return tget(gett) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -318,4 +318,4 @@ query = socket.protect(function(p)
|
|||||||
return data
|
return data
|
||||||
end)
|
end)
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -153,4 +153,4 @@ get = socket.protect(function(gett)
|
|||||||
else return tget(gett) end
|
else return tget(gett) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="h:\include"
|
AdditionalIncludeDirectories="..\..\include, compat-5.1r2"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport)"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport)"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -69,7 +69,7 @@
|
|||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include, compat-5.1r2"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG"
|
||||||
RuntimeLibrary="4"
|
RuntimeLibrary="4"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
@ -125,7 +125,7 @@
|
|||||||
RelativePath=".\buffer.c">
|
RelativePath=".\buffer.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\compat-5.1.c">
|
RelativePath=".\compat-5.1r2\compat-5.1.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\except.c">
|
RelativePath=".\except.c">
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
DIST = luasocket-2.0-beta3
|
DIST = luasocket-2.0-beta3
|
||||||
|
|
||||||
|
COMPAT = compat-5.1r2
|
||||||
|
|
||||||
LUA = \
|
LUA = \
|
||||||
ftp.lua \
|
ftp.lua \
|
||||||
http.lua \
|
http.lua \
|
||||||
@ -11,7 +13,6 @@ LUA = \
|
|||||||
mime.lua \
|
mime.lua \
|
||||||
smtp.lua \
|
smtp.lua \
|
||||||
socket.lua \
|
socket.lua \
|
||||||
compat-5.1.lua \
|
|
||||||
tp.lua \
|
tp.lua \
|
||||||
url.lua
|
url.lua
|
||||||
|
|
||||||
@ -72,9 +73,7 @@ CORE = \
|
|||||||
usocket.c \
|
usocket.c \
|
||||||
usocket.h \
|
usocket.h \
|
||||||
wsocket.c \
|
wsocket.c \
|
||||||
wsocket.h \
|
wsocket.h
|
||||||
compat-5.1.c \
|
|
||||||
compat-5.1.h
|
|
||||||
|
|
||||||
MAKE = \
|
MAKE = \
|
||||||
makefile.Darwin \
|
makefile.Darwin \
|
||||||
@ -92,7 +91,7 @@ MANUAL = \
|
|||||||
manual/ltn12.html \
|
manual/ltn12.html \
|
||||||
manual/luasocket.png \
|
manual/luasocket.png \
|
||||||
manual/mime.html \
|
manual/mime.html \
|
||||||
manual/instalation.html \
|
manual/installation.html \
|
||||||
manual/reference.css \
|
manual/reference.css \
|
||||||
manual/reference.html \
|
manual/reference.html \
|
||||||
manual/smtp.html \
|
manual/smtp.html \
|
||||||
@ -107,6 +106,7 @@ dist:
|
|||||||
mkdir -p $(DIST)/etc
|
mkdir -p $(DIST)/etc
|
||||||
mkdir -p $(DIST)/lua
|
mkdir -p $(DIST)/lua
|
||||||
mkdir -p $(DIST)/manual
|
mkdir -p $(DIST)/manual
|
||||||
|
cp -vfr $(COMPAT) $(DIST)
|
||||||
cp -vf TODO $(DIST)
|
cp -vf TODO $(DIST)
|
||||||
cp -vf $(CORE) $(DIST)
|
cp -vf $(CORE) $(DIST)
|
||||||
cp -vf README $(DIST)
|
cp -vf README $(DIST)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="h:\include"
|
AdditionalIncludeDirectories="..\..\include, compat-5.1r2"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport)"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport)"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -68,7 +68,7 @@
|
|||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include, compat-5.1r2"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)"
|
||||||
RuntimeLibrary="4"
|
RuntimeLibrary="4"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
@ -117,7 +117,7 @@
|
|||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||||
<File
|
<File
|
||||||
RelativePath=".\compat-5.1.c">
|
RelativePath=".\compat-5.1r2\compat-5.1.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\mime.c">
|
RelativePath=".\mime.c">
|
||||||
|
@ -7,7 +7,7 @@ is not supported.
|
|||||||
listener.lua and talker.lua are about the simplest applications you can
|
listener.lua and talker.lua are about the simplest applications you can
|
||||||
write using LuaSocket. Run
|
write using LuaSocket. Run
|
||||||
|
|
||||||
'lua listen.lua' and 'lua talk.lua'
|
'lua listener.lua' and 'lua talker.lua'
|
||||||
|
|
||||||
on different terminals. Whatever you type on talk.lua will be
|
on different terminals. Whatever you type on talk.lua will be
|
||||||
printed by listen.lua.
|
printed by listen.lua.
|
||||||
|
@ -12,13 +12,13 @@ if arg then
|
|||||||
port = arg[2] or port
|
port = arg[2] or port
|
||||||
end
|
end
|
||||||
host = socket.dns.toip(host)
|
host = socket.dns.toip(host)
|
||||||
udp = socket.try(socket.udp())
|
udp = assert(socket.udp())
|
||||||
socket.try(udp:setpeername(host, port))
|
assert(udp:setpeername(host, port))
|
||||||
print("Using remote host '" ..host.. "' and port " .. port .. "...")
|
print("Using remote host '" ..host.. "' and port " .. port .. "...")
|
||||||
while 1 do
|
while 1 do
|
||||||
line = io.read()
|
line = io.read()
|
||||||
if not line then os.exit() end
|
if not line or line == "" then os.exit() end
|
||||||
socket.try(udp:send(line))
|
assert(udp:send(line))
|
||||||
dgram = socket.try(udp:receive())
|
dgram = assert(udp:receive())
|
||||||
print(dgram)
|
print(dgram)
|
||||||
end
|
end
|
||||||
|
@ -12,10 +12,11 @@ if arg then
|
|||||||
port = arg[2] or port
|
port = arg[2] or port
|
||||||
end
|
end
|
||||||
print("Binding to host '" ..host.. "' and port " ..port.. "...")
|
print("Binding to host '" ..host.. "' and port " ..port.. "...")
|
||||||
udp = socket.try(socket.udp())
|
udp = assert(socket.udp())
|
||||||
socket.try(udp:setsockname(host, port))
|
assert(udp:setsockname(host, port))
|
||||||
socket.try(udp:settimeout(5))
|
assert(udp:settimeout(5))
|
||||||
ip, port = socket.try(udp:getsockname())
|
ip, port = udp:getsockname()
|
||||||
|
assert(ip, port)
|
||||||
print("Waiting packets on " .. ip .. ":" .. port .. "...")
|
print("Waiting packets on " .. ip .. ":" .. port .. "...")
|
||||||
while 1 do
|
while 1 do
|
||||||
dgram, ip, port = udp:receivefrom()
|
dgram, ip, port = udp:receivefrom()
|
||||||
|
@ -12,10 +12,11 @@ if arg then
|
|||||||
port = arg[2] or port
|
port = arg[2] or port
|
||||||
end
|
end
|
||||||
print("Binding to host '" ..host.. "' and port " ..port.. "...")
|
print("Binding to host '" ..host.. "' and port " ..port.. "...")
|
||||||
s = socket.try(socket.bind(host, port))
|
s = assert(socket.bind(host, port))
|
||||||
i, p = socket.try(s:getsockname())
|
i, p = s:getsockname()
|
||||||
|
assert(i, p)
|
||||||
print("Waiting connection from talker on " .. i .. ":" .. p .. "...")
|
print("Waiting connection from talker on " .. i .. ":" .. p .. "...")
|
||||||
c = socket.try(s:accept())
|
c = assert(s:accept())
|
||||||
print("Connected. Here is the stuff:")
|
print("Connected. Here is the stuff:")
|
||||||
l, e = c:receive()
|
l, e = c:receive()
|
||||||
while not e do
|
while not e do
|
||||||
|
@ -12,10 +12,10 @@ if arg then
|
|||||||
port = arg[2] or port
|
port = arg[2] or port
|
||||||
end
|
end
|
||||||
print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
|
print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
|
||||||
c = socket.try(socket.connect(host, port))
|
c = assert(socket.connect(host, port))
|
||||||
print("Connected! Please type stuff (empty line to stop):")
|
print("Connected! Please type stuff (empty line to stop):")
|
||||||
l = io.read()
|
l = io.read()
|
||||||
while l and l ~= "" and not e do
|
while l and l ~= "" and not e do
|
||||||
socket.try(c:send(l, "\n"))
|
assert(c:send(l .. "\n"))
|
||||||
l = io.read()
|
l = io.read()
|
||||||
end
|
end
|
||||||
|
@ -14,8 +14,8 @@ if arg then
|
|||||||
port2 = arg[3] or port2
|
port2 = arg[3] or port2
|
||||||
end
|
end
|
||||||
|
|
||||||
server1 = socket.try(socket.bind(host, port1))
|
server1 = assert(socket.bind(host, port1))
|
||||||
server2 = socket.try(socket.bind(host, port2))
|
server2 = assert(socket.bind(host, port2))
|
||||||
server1:settimeout(1) -- make sure we don't block in accept
|
server1:settimeout(1) -- make sure we don't block in accept
|
||||||
server2:settimeout(1)
|
server2:settimeout(1)
|
||||||
|
|
||||||
|
@ -278,4 +278,4 @@ get = socket.protect(function(gett)
|
|||||||
else return tget(gett) end
|
else return tget(gett) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -259,4 +259,4 @@ request = socket.protect(function(reqt, body)
|
|||||||
else return trequest(reqt) end
|
else return trequest(reqt) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -170,20 +170,16 @@ end
|
|||||||
|
|
||||||
-- creates a source that produces contents of several sources, one after the
|
-- creates a source that produces contents of several sources, one after the
|
||||||
-- other, as if they were concatenated
|
-- other, as if they were concatenated
|
||||||
|
-- (thanks to Wim Couwenberg)
|
||||||
function source.cat(...)
|
function source.cat(...)
|
||||||
local co = coroutine.create(function()
|
local src = table.remove(arg, 1)
|
||||||
local i = 1
|
|
||||||
while i <= table.getn(arg) do
|
|
||||||
local chunk, err = arg[i]()
|
|
||||||
if chunk then coroutine.yield(chunk)
|
|
||||||
elseif err then return nil, err
|
|
||||||
else i = i + 1 end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
return function()
|
return function()
|
||||||
local ret, a, b = coroutine.resume(co)
|
while src do
|
||||||
if ret then return a, b
|
local chunk, err = src()
|
||||||
else return nil, a end
|
if chunk then return chunk end
|
||||||
|
if err then return nil, err end
|
||||||
|
src = table.remove(arg, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -276,4 +272,4 @@ function pump.all(src, snk, step)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -13,7 +13,9 @@
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Current luasocket version
|
* Current luasocket version
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)"
|
#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)"
|
||||||
|
#define LUASOCKET_COPYRIGHT "Copyright (C) 2004-2005 Diego Nehab"
|
||||||
|
#define LUASOCKET_AUTHORS "Diego Nehab"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* This macro prefixes all exported API functions
|
* This macro prefixes all exported API functions
|
||||||
|
@ -85,4 +85,4 @@ function mime.stuff()
|
|||||||
return ltn12.filter.cycle(dot, 2)
|
return ltn12.filter.cycle(dot, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -245,4 +245,4 @@ send = socket.protect(function(mailt)
|
|||||||
return s:close()
|
return s:close()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -172,4 +172,4 @@ socket.sourcet["default"] = socket.sourcet["until-closed"]
|
|||||||
|
|
||||||
socket.source = socket.choose(socket.sourcet)
|
socket.source = socket.choose(socket.sourcet)
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -120,4 +120,4 @@ function connect(host, port, timeout)
|
|||||||
return base.setmetatable({c = c}, metat)
|
return base.setmetatable({c = c}, metat)
|
||||||
end
|
end
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -273,4 +273,4 @@ function build_path(parsed, unsafe)
|
|||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
getmetatable(_M).__index = nil
|
--getmetatable(_M).__index = nil
|
||||||
|
@ -23,7 +23,7 @@ http.TIMEOUT = 10
|
|||||||
local t = socket.gettime()
|
local t = socket.gettime()
|
||||||
|
|
||||||
host = host or "diego.student.princeton.edu"
|
host = host or "diego.student.princeton.edu"
|
||||||
proxy = proxy or "http://localhost:3128"
|
proxy = proxy or "http://dell-diego:3128"
|
||||||
prefix = prefix or "/luasocket-test"
|
prefix = prefix or "/luasocket-test"
|
||||||
cgiprefix = cgiprefix or "/luasocket-test-cgi"
|
cgiprefix = cgiprefix or "/luasocket-test-cgi"
|
||||||
index_file = "test/index.html"
|
index_file = "test/index.html"
|
||||||
@ -399,7 +399,6 @@ print("ok")
|
|||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
io.write("testing HEAD method: ")
|
io.write("testing HEAD method: ")
|
||||||
http.TIMEOUT = 1
|
|
||||||
local r, c, h = http.request {
|
local r, c, h = http.request {
|
||||||
method = "HEAD",
|
method = "HEAD",
|
||||||
url = "http://www.cs.princeton.edu/~diego/"
|
url = "http://www.cs.princeton.edu/~diego/"
|
||||||
|
Loading…
Reference in New Issue
Block a user