BUG: Windows related bugs in juce_Socket.cpp

I’ve turned on a few warnings that are “off” by default (even with /W4) and it correctly shows that juce_Socket.cpp has three “expression always true/false” errors that would cause erroneous behavior:

juce_Socket.cpp(90,23): warning C4296:  '>=': expression is always true (compiling source file ..\..\JuceLibraryCode\include_juce_core.cpp)
juce_Socket.cpp(150,20): warning C4296:  '<': expression is always false (compiling source file ..\..\JuceLibraryCode\include_juce_core.cpp)
juce_Socket.cpp(166,20): warning C4296:  '>=': expression is always true (compiling source file ..\..\JuceLibraryCode\include_juce_core.cpp)

In all three cases, a SocketHandle is compared as if it’s a signed value ( >=0 or < 0) but on Windows a SocketHandle is an unsigned type and thus it has to be explicitly compared to “INVALID_SOCKET”.

There is even a static const in Juce_Socket.cpp that defines an invalidSocket, but it’s not used in these three cases.

Thanks! I’ve pushed a fix here.

1 Like

Thanks