【发布时间】:2017-01-17 02:21:07
【问题描述】:
我正在使用 lualoader,并从 webserver example 加载了以下脚本
-- a simple http server
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
conn:on("receive", function(sck, payload)
print(payload)
sck:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h1> Hello, NodeMCU.</h1>")
end)
conn:on("sent", function(sck) sck:close() end)
end)
我将它保存在一个文件中并将其加载到 lualoader,然后执行dofile。每当我加载向 esp8266 发送 HTTP 请求时,它都会加载网页。即使在运行其他脚本之后也是如此。从阅读脚本来看,它似乎只能处理一个 HTTP 请求。为什么它一直在处理新的 http 请求?
【问题讨论】: