Error in creating TCP client in lua -
i trying create tcp client in lua
local host, port = host, port local socket = require("socket") client = socket.tcp(); client:connect(host, port); client:send("hello user");
this works fine when add
while true local s, status, partial = client:receive() print(s or partial) if status == "closed" break end end
to read data socket block total execution of code.
by default, luasocket i/o operations blocking. need use socket.settimeout(0)
(settimeout) disable blocking. can check "timeout" value returned status , act accordingly.
depending on how data being sent, this answer may relevant well.
Comments
Post a Comment