首先弄个配置文件,这样就可以随时配置想要下载的文件和存储路径
Like this: // config.lua
local Config = {}
local Request =
{
{
host = "pic2.zhimg.com",
port = 80,
path = "/80/v2-fdad05ad3f2b8ff3f64a8440f31adf92_hd.jpg",
save = "v2-fdad05ad3f2b8ff3f64a8440f31adf92_hd.jpg"
},
{
host = "pic4.zhimg.com",
port = 80,
path = "/80/v2-f7e4a1d2ab3d791125b5c073b17a71c9_hd.jpg",
save = "v2-f7e4a1d2ab3d791125b5c073b17a71c9_hd.jpg"
},
{
host = "pic1.zhimg.com",
port = 80,
path = "/80/v2-3d769bced4b30df15ebfedef71a18e21_hd.jpg",
save = "v2-3d769bced4b30df15ebfedef71a18e21_hd.jpg"
}
}
Config.Request = Request
return Config
再来个多线程下载 // download.lua
local Socket = require("socket")
function async_receive(conn)
local response,status,partial = conn:receive(2 ^ 10)
if status == "timeout&