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
|
||||
*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
|
||||
|
||||
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
|
||||
end)
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -318,4 +318,4 @@ query = socket.protect(function(p)
|
||||
return data
|
||||
end)
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -153,4 +153,4 @@ get = socket.protect(function(gett)
|
||||
else return tget(gett) end
|
||||
end)
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -19,7 +19,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="h:\include"
|
||||
AdditionalIncludeDirectories="..\..\include, compat-5.1r2"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport)"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -69,7 +69,7 @@
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
AdditionalIncludeDirectories="../../include, compat-5.1r2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
@ -125,7 +125,7 @@
|
||||
RelativePath=".\buffer.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\compat-5.1.c">
|
||||
RelativePath=".\compat-5.1r2\compat-5.1.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\except.c">
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
DIST = luasocket-2.0-beta3
|
||||
|
||||
COMPAT = compat-5.1r2
|
||||
|
||||
LUA = \
|
||||
ftp.lua \
|
||||
http.lua \
|
||||
@ -11,7 +13,6 @@ LUA = \
|
||||
mime.lua \
|
||||
smtp.lua \
|
||||
socket.lua \
|
||||
compat-5.1.lua \
|
||||
tp.lua \
|
||||
url.lua
|
||||
|
||||
@ -72,9 +73,7 @@ CORE = \
|
||||
usocket.c \
|
||||
usocket.h \
|
||||
wsocket.c \
|
||||
wsocket.h \
|
||||
compat-5.1.c \
|
||||
compat-5.1.h
|
||||
wsocket.h
|
||||
|
||||
MAKE = \
|
||||
makefile.Darwin \
|
||||
@ -92,7 +91,7 @@ MANUAL = \
|
||||
manual/ltn12.html \
|
||||
manual/luasocket.png \
|
||||
manual/mime.html \
|
||||
manual/instalation.html \
|
||||
manual/installation.html \
|
||||
manual/reference.css \
|
||||
manual/reference.html \
|
||||
manual/smtp.html \
|
||||
@ -107,6 +106,7 @@ dist:
|
||||
mkdir -p $(DIST)/etc
|
||||
mkdir -p $(DIST)/lua
|
||||
mkdir -p $(DIST)/manual
|
||||
cp -vfr $(COMPAT) $(DIST)
|
||||
cp -vf TODO $(DIST)
|
||||
cp -vf $(CORE) $(DIST)
|
||||
cp -vf README $(DIST)
|
||||
|
@ -19,7 +19,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="h:\include"
|
||||
AdditionalIncludeDirectories="..\..\include, compat-5.1r2"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport)"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -68,7 +68,7 @@
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
AdditionalIncludeDirectories="../../include, compat-5.1r2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
@ -117,7 +117,7 @@
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\compat-5.1.c">
|
||||
RelativePath=".\compat-5.1r2\compat-5.1.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\mime.c">
|
||||
|
@ -7,7 +7,7 @@ is not supported.
|
||||
listener.lua and talker.lua are about the simplest applications you can
|
||||
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
|
||||
printed by listen.lua.
|
||||
|
@ -12,13 +12,13 @@ if arg then
|
||||
port = arg[2] or port
|
||||
end
|
||||
host = socket.dns.toip(host)
|
||||
udp = socket.try(socket.udp())
|
||||
socket.try(udp:setpeername(host, port))
|
||||
udp = assert(socket.udp())
|
||||
assert(udp:setpeername(host, port))
|
||||
print("Using remote host '" ..host.. "' and port " .. port .. "...")
|
||||
while 1 do
|
||||
line = io.read()
|
||||
if not line then os.exit() end
|
||||
socket.try(udp:send(line))
|
||||
dgram = socket.try(udp:receive())
|
||||
if not line or line == "" then os.exit() end
|
||||
assert(udp:send(line))
|
||||
dgram = assert(udp:receive())
|
||||
print(dgram)
|
||||
end
|
||||
|
@ -12,10 +12,11 @@ if arg then
|
||||
port = arg[2] or port
|
||||
end
|
||||
print("Binding to host '" ..host.. "' and port " ..port.. "...")
|
||||
udp = socket.try(socket.udp())
|
||||
socket.try(udp:setsockname(host, port))
|
||||
socket.try(udp:settimeout(5))
|
||||
ip, port = socket.try(udp:getsockname())
|
||||
udp = assert(socket.udp())
|
||||
assert(udp:setsockname(host, port))
|
||||
assert(udp:settimeout(5))
|
||||
ip, port = udp:getsockname()
|
||||
assert(ip, port)
|
||||
print("Waiting packets on " .. ip .. ":" .. port .. "...")
|
||||
while 1 do
|
||||
dgram, ip, port = udp:receivefrom()
|
||||
|
@ -12,10 +12,11 @@ if arg then
|
||||
port = arg[2] or port
|
||||
end
|
||||
print("Binding to host '" ..host.. "' and port " ..port.. "...")
|
||||
s = socket.try(socket.bind(host, port))
|
||||
i, p = socket.try(s:getsockname())
|
||||
s = assert(socket.bind(host, port))
|
||||
i, p = s:getsockname()
|
||||
assert(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:")
|
||||
l, e = c:receive()
|
||||
while not e do
|
||||
|
@ -12,10 +12,10 @@ if arg then
|
||||
port = arg[2] or port
|
||||
end
|
||||
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):")
|
||||
l = io.read()
|
||||
while l and l ~= "" and not e do
|
||||
socket.try(c:send(l, "\n"))
|
||||
assert(c:send(l .. "\n"))
|
||||
l = io.read()
|
||||
end
|
||||
|
@ -14,8 +14,8 @@ if arg then
|
||||
port2 = arg[3] or port2
|
||||
end
|
||||
|
||||
server1 = socket.try(socket.bind(host, port1))
|
||||
server2 = socket.try(socket.bind(host, port2))
|
||||
server1 = assert(socket.bind(host, port1))
|
||||
server2 = assert(socket.bind(host, port2))
|
||||
server1:settimeout(1) -- make sure we don't block in accept
|
||||
server2:settimeout(1)
|
||||
|
||||
|
@ -278,4 +278,4 @@ get = socket.protect(function(gett)
|
||||
else return tget(gett) 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
|
||||
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
|
||||
-- other, as if they were concatenated
|
||||
-- (thanks to Wim Couwenberg)
|
||||
function source.cat(...)
|
||||
local co = coroutine.create(function()
|
||||
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)
|
||||
local src = table.remove(arg, 1)
|
||||
return function()
|
||||
local ret, a, b = coroutine.resume(co)
|
||||
if ret then return a, b
|
||||
else return nil, a end
|
||||
while src do
|
||||
local chunk, err = src()
|
||||
if chunk then return chunk end
|
||||
if err then return nil, err end
|
||||
src = table.remove(arg, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -276,4 +272,4 @@ function pump.all(src, snk, step)
|
||||
end
|
||||
end
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -14,6 +14,8 @@
|
||||
* Current luasocket version
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#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
|
||||
|
@ -85,4 +85,4 @@ function mime.stuff()
|
||||
return ltn12.filter.cycle(dot, 2)
|
||||
end
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -245,4 +245,4 @@ send = socket.protect(function(mailt)
|
||||
return s:close()
|
||||
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)
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -120,4 +120,4 @@ function connect(host, port, timeout)
|
||||
return base.setmetatable({c = c}, metat)
|
||||
end
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -273,4 +273,4 @@ function build_path(parsed, unsafe)
|
||||
return path
|
||||
end
|
||||
|
||||
getmetatable(_M).__index = nil
|
||||
--getmetatable(_M).__index = nil
|
||||
|
@ -23,7 +23,7 @@ http.TIMEOUT = 10
|
||||
local t = socket.gettime()
|
||||
|
||||
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"
|
||||
cgiprefix = cgiprefix or "/luasocket-test-cgi"
|
||||
index_file = "test/index.html"
|
||||
@ -399,7 +399,6 @@ print("ok")
|
||||
|
||||
------------------------------------------------------------------------
|
||||
io.write("testing HEAD method: ")
|
||||
http.TIMEOUT = 1
|
||||
local r, c, h = http.request {
|
||||
method = "HEAD",
|
||||
url = "http://www.cs.princeton.edu/~diego/"
|
||||
|
Loading…
Reference in New Issue
Block a user