[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can there be a better way of doing non-blocking data reads with LuaSocket?
- From: Diego Nehab <diego@...>
- Date: Wed, 12 Nov 2008 04:15:10 -0500 (EST)
Hi,
Btw, do these examples seem weird?
No.
s=socket.connect("localhost", 80)
s:settimeout(0)
= s:receive(0)
nil timeout
Either "timeout" or "" would be fine here. Unless the
connection is closed, in which case you should receive the
notification. My choice seems consistent with the behavior
below.
s=socket.connect("localhost", 80)
= s:receive(0)
.... blocks forever....
What is it waiting for? Either return a zero-length string, or return
an argument error.
I think this is standard behavior. When and if new data
arrives, it will return you the empty string. Or when the
connection is closed, it will also let you know.
Regards,
Diego