New function for juce_Socket


function to get the amount of data available to be read by the function read ()

for juce_Socket.cpp in namespace SocketHelpers

static int pendingForReadingSocket (const int handle) { int ret=0; int bytes = 0; #if JUCE_WINDOWS ret=ioctlsocket(handle, FIONREAD, &bytes); #else ret=ioctl(handle, FIONREAD, &bytes); #endif ret!=0?return -1:return bytes; }


Code relying this would be badly architectured.
This is racy (between the moment you ask for the pending size and the moment you read it, you might have more data, or worst, some other thread might have read it).
The right way to deal with the unknown amount issue is to be prepared for any amount, selecting for it, and not expecting a value the kernel reports at a given point in time.

It’s not by chance that the socket protocol was called Stream.