chrisroberts / krakow

Ruby client library for NSQ
Other
99 stars 17 forks source link

Ensure all bytes of a message are received #8

Closed thomas-holmes closed 10 years ago

thomas-holmes commented 10 years ago

#recv only has to provide up to the amount of requested bytes so it can terminate on large messages. Use #read instead which delivers exactly the requested number of bytes.

thomas-holmes commented 10 years ago

Another option is to loop around #recv until the desired amount of bytes have been retrieved. I have tried both and this is a smaller code change. It's possible that looping with #recv might allow for better behavior around an unstable network situation.

I'm not exactly sure how to write a test for this, I only encountered the problem with large messages (4000+ bytes) when going between machines.

chrisroberts commented 10 years ago

:+1:

chrisroberts commented 10 years ago

Applied. Thanks!