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