lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

On Nov 24, 2005, at 20:46, Diego Nehab wrote:

The change was simple. The send() function used to return the number of
bytes LuaSocket managed to get rid of by passing them down to the
transport layer. When using non-blocking I/O, we send the data piece by piece. So the send() function accepts the indices of the first and last byte of a string you want to send. This avoids the creation of temporary strings
that would be created by string.sub. Now, if you look at your loop, you
had to advance the initial position by the number of bytes that send()
actually sent. Every time you use non-blocking I/O, you would have to do this. So now LuaSocket returns the index of the last byte that was sent.
On the next call, you can simply use that index.

Thanks for the clarification. I will adapt my code accordantly by removing one variable :)

        local aStatus = nil
        local anIndex = 0
        local aSize = 0

        while true do
aSize, aStatus, anIndex = self:socket():send( aValue, anIndex + 1 )

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/