-2
我正在做一個與以Lua語言創建TCP/IP通信有關的項目。我的電腦將成爲一臺服務器,我想將它連接到另一臺電腦。Lua中的TCP/IP問題
所以,這裏是代碼:
local socket = require'socket'
local server = socket.tcp()
server:bind('*', 7200)
server:listen(32)
>>>>local client = server:accept()
--Here I have a problem. It is not working.
--It says:
--calling 'accept' on bad self (tcp{server} expected,got userdata in function)
client:settimeout(10)
-- receive the line
local line, err = client:receive()
-- if there was no error, send it back to the client
if not err then
client:send('test') --end
-- done with client, close the object
client:close()
哪裏我犯了一個錯誤?