同步操作将从 fulinux/lua 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/lualocal socket = require("socket")function receive (connection)connection:settimeout(0)local s, status, partial = connection:receive(1024)if status == "timeout" thencoroutine.yield(connection)endreturn s or partial, statusendfunction download (host, file)-- 创建一个 TCP 连接,连接到 HTTP 连接的标准端口 -- 80 端口上local sock = assert(socket.connect(host, 80))local count = 0sock:send("GET " .. file .. " HTTP/1.0\r\n\r\n")while true do-- 以 1K 的字节块来接收数据,并把接收到字节块输出来local s, status, partial = sock:receive(1024)count = count + #(s or partial)if status == "closed" then break endendsock:close()print(file, count)endthreads = {}function get (host, file)local co = coroutine.create(function()download(host, file)end)table.insert(threads, co)endfunction dispatch ()local i = 1local connections = {}while true doif threads[i] == nil thenif threads[1] == nil then break endi = 1connections = {}endlocal status, res = coroutine.resume(threads[i])if not res thentable.remove(threads, i)elsei = i + 1connections[#connections + 1] = resif #connections == #threads thensocket.select(connections)endendendendhost = "www.w3.org"get(host, "/TR/html401/html40.txt")get(host, "/TR/2002/REC-xhtml1-20020801/xhtml1.pdf")get(host, "/TR/REC-html32.html")get(host, "/TR/2000/REC-DOM-Level-2-Core-20001113/DOM2-Core.txt")dispatch() -- main loop
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。