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

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -