How many bytes are available is not a fixed number when dealing with byte streams, it can change at any time.
You can use the version of recv with a timeout and a suitably large number
Or mess about with ioctl and FIONREAD but it's almost never worth it