以 socket 的方式访问

脚本示例:

local sz = require("sz")
local http = require("szocket.http")
local host = "www.baidu.com"
local file = "/"
--创建一个 TCP 连接,连接到 HTTP 连接的标准 80 端口上
local sock = assert(socket.connect(host, 80)) 
sock:send("GET " .. file .. " HTTP/1.0\r\n\r\n")
repeat
    --以 1K 的字节块接收数据
    local chunk, status, partial = sock:receive(1024) 
until status ~= "closed"
-- 关闭 TCP 连接
sock:close()
Copyright 北京帮你玩科技有限公司 2020 all right reserved,powered by Gitbook该文章修订时间: 2020-01-19 17:41:57

results matching ""

    No results matching ""