redding/sanford-protocol — pull request #15 by jcredding (2013-01-30 22:27:26+00:00)
Title: Correctly detect end-of-file for a socket

Apparently it's not safe to mix system calls (`recvfrom`) and
buffered IO methods (`eof?`). I found a couple mentions of this,
nothing definitive, but when I tried using this in Sanford, I
ran into issues with an error message like:

`"recv for buffered io"`

It seems the only proper way to detect "end-of-file" (closed on
the remote end) for a socket that uses `recvfrom` is to see if it
returns a response of 0 bytes. This produces the same result (in
this gem) as the previous implementation, but additionally works
as expected in Sanford.