[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaSocket nonblocking receive() semantics
- From: Sam Roberts <vieuxtech@...>
- Date: Thu, 15 Mar 2012 13:29:35 -0700
On Thu, Mar 15, 2012 at 12:40 PM, Matthew Wild <mwild1@gmail.com> wrote:
> On 15 March 2012 19:19, Flemming Madsen <lua@themadsens.dk> wrote:
>> Speaking of LuaSocket .. I have a small request ..
>>
>> Could we have receive() behavior ala Posix read().
>>
>> Ie. after select() reports a steam readable, the next receive() can be
>> specified non-blocking, no matter the number of requested bytes, and the
>> number of actually received bytes is returned.
>>
>> (A new function, negative count dor receive(), whatever)
> Are you missing conn:settimeout(0)? If not, do you have a test case
> where receive() blocks?
I'm confused, too. Is it possible that what you want to do is
receive() as much data as is currently available, as soon as select()
says a socket is readable?
This is the most basic usage of the BSD socket API, and while not
directly supported by luasocket, you can do it like this:
https://github.com/sam-github/swirl/blob/master/lua/sockext.lua, see line 39.
Sam