2012-04-11 9 views
1

プラットフォーム:(LuaとLuaSocketが移植されています) TCP/IPスタックでサードパーティのRTOSを実行するARM 7開発ボードを使用する組み込みシステム。LuaSocket - 'try'フィールドを呼び出そうとしました。

何作品:

  • を、このようなUDP =アサート(socket.udp)メソッドを使用してUDPパケットを送信する "IO" の呼び出し、印刷、主張など
  • などLuaの標準ライブラリを使用して、(主張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; 
} 

答えて

2

まあ、 "try is nil"というエラーが表示されるので、私の最高の推測は、C libが正しくないか、完全ではなく、あなたのLuaにリンクしているということです。これは、誤ったインストール、欠落したlib、またはそのようなものの結果である可能性があります。

+0

こんにちは、あなたのおかげです。私はソケットの "コア"ライブラリを静的にリンクすることで問題を解決したと思います。ありがとうございました! – user1325966

+0

その場合、私の回答に有効な印を付けてください。この回答の左側にある「グレーの✔記号」をクリックすると、緑色に変わります。 – kikito

+0

これも私に起こった。実際に、彼はこのlib https://github.com/hjelmeland/try-lua/blob/master/try.luaがありません。 –

関連する問題