[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua socket programming examples
- From: Sam Roberts <vieuxtech@...>
- Date: Sun, 6 Mar 2011 20:58:08 -0800
On Sun, Mar 6, 2011 at 9:46 AM, Jayanth Acharya <email@example.com> wrote:
> What I would like to understand is how to deal with receive buffers in Lua,
Not sure what this means.
> how to to stitch together segmented TCP data to identify message boundaries
> (given message-length in the application protocol) etc. The message is all
Look at the receive() docs for tcp. You can do a read, specifying the
size of the fixed size header.
Then use struct or pack (search on luaforge) to decode the size from
the header, and read
the rest of the PDU.
luasocket will read repeatedly until it gets end-of-stream or the
amount of data you asked for. If you are dealing with multiple
streams, use select, set timeouts, and collect and concatenate the
> binary data, and need to do lot of byte-order (htonX / ntohX) corrections
> etc. I'd prefer the example to be pure Lua, and using LuaSocket.
After you try you'll be well positioned to repost with specific questions.