Socket Communication
WARNING
When network communication is abnormal, this library may cause the system to freeze or crash.
Built-in luasocket
library, which can be used for Socket communication. For details, see LuaSocket Documentation.
Example
local http = require("socket.http")
local json = require("json")
body, code, header = http.request("http://10.20.17.1/public/api/condition_tasks")
data = json.decode(body)
print(data, code, header)
Output result:
{code=2005} 404 {connection=close,content-type=application/json; charset=utf-8,content-length=25,date=Wed, 07 Apr 2021 10:28:07 GMT,cache-control=no-cache}