Check for available data on the socket before trying to read it
Merge pull request #1 from lordp/master

Check for available data on the socket before trying to read it