Comparison

net/server_select.lua @ 2312:5ddbb9c89ffe

net.server_select: Restore checks for wantread/timeout errors on receive
author Matthew Wild <mwild1@gmail.com>
date Thu, 03 Dec 2009 19:18:18 +0000
parent 2307:fc7e0962520a
child 2318:a831de056de3
comparison
equal deleted inserted replaced
2311:5fe837ebe542 2312:5ddbb9c89ffe
472 end 472 end
473 return noread, nosend 473 return noread, nosend
474 end 474 end
475 local _readbuffer = function( ) -- this function reads data 475 local _readbuffer = function( ) -- this function reads data
476 local buffer, err, part = receive( socket, pattern ) -- receive buffer with "pattern" 476 local buffer, err, part = receive( socket, pattern ) -- receive buffer with "pattern"
477 if not err or string_len(part) > 0 then -- received something 477 if not err or (err == "wantread" or err == "timeout") or string_len(part) > 0 then -- received something
478 local buffer = buffer or part or "" 478 local buffer = buffer or part or ""
479 local len = string_len( buffer ) 479 local len = string_len( buffer )
480 if len > maxreadlen then 480 if len > maxreadlen then
481 disconnect( handler, "receive buffer exceeded" ) 481 disconnect( handler, "receive buffer exceeded" )
482 handler.close( true ) 482 handler.close( true )