Hello!
On Mon, Jul 28, 2014 at 6:37 AM, Xiaofei Yang wrote:
> while true do
> local chunk, err = sock:receive(1024)
> if not chunk then
> if err == "closed" then
> break
> end
>
> ngx.say("faile to read: ", err)
> return
> end
> process_chunk(chunk)
> end
>
> The remaining piece of data which is less than 1024 is always truncated in
> my case.
> How to get complete data?
In this case, just read the 3rd return value from receive():
local data, err, partial = tcpsock:receive(size)
Check out the official documentation of receive() for more details:
https://github.com/openresty/lua-nginx-module#tcpsockreceive
Yeah, the rule of thumb is: when in doubt, read the manual.
BTW, this is the Chinese mailing list. If you really want to use
English for discussion, please join the openresty-en mailing list
instead: https://groups.google.com/group/openresty-en Thank you for
your cooperation!
Best regards,
-agentzh