1
平台:(其中Lua和LuaSocket被移植) 嵌入式系统使用ARM 7开发板运行带有TCP/IP协议栈的第三方RTOS。LuaSocket - 试图调用字段'尝试'(一个零值)
什么工作:
- 使用Lua标准库,如 “IO” 电话,打印,断言等
- 使用UDP =断言(socket.udp)方法发送UDP数据包,断言( UDP:发送(东西))
问题: 当执行一个例子SMTP LUA脚本:
local smtp = require("socket.smtp")
from = "myEmail"
rcpt = {"<someOne's Email>"}
mesgt = { heasers = {someHeader}, body = "Hello World" }
r, e = smtp.send {
from = from,
rcpt = rcpt,
source = smtp.message(mesgt),
server = "someServer",
port = 25,
}
-- an error returns after execution:
-- lua\socket\smtp.lua:115: attempt to call field 'try' (a nil value)
-- Corresponding code in smtp.lua around line 115:
function open(server, port, create)
local tp = socket.try(tp.connect(server or SERVER, port or PORT,
TIMEOUT, create))
local s = base.setmetatable({tp = tp}, metat)
-- make sure tp is closed if we get an exception
s.try = socket.newtry(function()
s:close()
end)
return s
end
// Where try = newtry() in socket.lua and the corresponding C code is the same
// from the one provided with the library for UNIX:
static int global_newtry(lua_State *L) {
lua_settop(L, 1);
if (lua_isnil(L, 1)) lua_pushcfunction(L, do_nothing);
lua_pushcclosure(L, finalize, 1);
return 1;
}
嗨Kikito,谢谢你的帮助。我想我通过静态连接我的套接字“核心”库来解决这个问题,我之前没有正确地做过。谢谢! – user1325966 2012-04-13 00:31:32
在这种情况下,您能否将我的答案标记为有效?只需点击此答案左侧的“灰色✔符号”,即可变为绿色。 – kikito 2012-04-13 08:56:24
这也发生在我身上。事实上,他缺少这个lib https://github.com/hjelmeland/try-lua/blob/master/try.lua。 – 2015-08-03 20:49:44