hWaitForInput with socket as handle excepts on windows
If I create a socket wrapped in a Handle (either by directly creating a handle with connectTo, or by creating a socket and wrapping it), hWaitForInput and hReady always give an exception with that handle. It excepts directly when calling, it does not wait until the given timeout of hWaitForInput has expired.
The following code exposes the bug (requiring that a server-socket is listening on port 7892):
module SockDebug where import System.IO import Network main = do sock <- connectTo "localhost" (Service $ show 7892) hWaitForInput sock 5000
Excepts with "hWaitForInput: invalid argument (Invalid argument)"
Happens both on windows 10 and windows 7.
This is the same error as in ticket 1198 so I'd guess that the bug is in cbits/inputReady.c as well, but I'm not an expert.