summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio/lua
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-02-15 13:59:30 +0000
committerSteven Barth <steven@midlink.org>2009-02-15 13:59:30 +0000
commit695361877cd094b1d8d15f3f4d8018eef2bc7b03 (patch)
treed7dbf86397b92e8fd656c07154128dcfd1ec63b1 /libs/nixio/lua
parent42793d87999519350eed6e0d4d44a0629ccbf4d4 (diff)
More nixio fixes
Diffstat (limited to 'libs/nixio/lua')
-rw-r--r--libs/nixio/lua/nixio/util.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/libs/nixio/lua/nixio/util.lua b/libs/nixio/lua/nixio/util.lua
index 8ad4040d4..34800b454 100644
--- a/libs/nixio/lua/nixio/util.lua
+++ b/libs/nixio/lua/nixio/util.lua
@@ -21,11 +21,13 @@ module "nixio.util"
local BUFFERSIZE = 8096
local socket = nixio.socket_meta
-function socket.readall(self, len)
+function socket.recvall(self, len)
local block, code, msg = self:recv(len)
if not block then
return "", code, msg, len
+ elseif #block == 0 then
+ return "", nil, nil, len
end
local data, total = {block}, #block
@@ -35,6 +37,8 @@ function socket.readall(self, len)
if not block then
return data, code, msg, len - #data
+ elseif #block == 0 then
+ return data, nil, nil, len - #data
end
data[#data+1], total = block, total + #block
@@ -66,11 +70,12 @@ end
function socket.linesource(self, limit)
limit = limit or BUFFERSIZE
local buffer = ""
+ local bpos = 0
return function(flush)
- local bpos, line, endp, _ = 0
+ local line, endp, _
if flush then
- line = buffer
+ line = buffer:sub(bpos + 1)
buffer = ""
return line
end