@@ -7,6 +7,10 @@ import qualified System.Posix.Internals
7
7
8
8
#if !defined(mingw32_HOST_OS)
9
9
import Network.Socket.Cbits
10
+ #else
11
+ # if defined(__IO_MANAGER_WINIO__)
12
+ import GHC.IO.SubSystem ((<!>) )
13
+ # endif
10
14
#endif
11
15
import Network.Socket.Imports
12
16
@@ -15,6 +19,7 @@ import Network.Socket.Imports
15
19
setNonBlockIfNeeded :: CSocket -> IO ()
16
20
setNonBlockIfNeeded fd =
17
21
System.Posix.Internals. setNonBlockingFD (fromIntegral fd) True
22
+
18
23
-- TODO: remove fromIntegral for WinIO
19
24
20
25
-- | Set the close_on_exec flag on Unix.
@@ -48,13 +53,20 @@ getCloseOnExec fd = do
48
53
#endif
49
54
50
55
-- | Get the nonblocking flag.
51
- -- On Windows, this function always returns 'False'.
56
+ -- On Windows, this function always returns 'False' when using MIO but
57
+ -- returns `True` when using WinIO. Technically on Windows whether the
58
+ -- the socket blocks or not is not determined by the socket itself but
59
+ -- by the operations used on the socket. Becuase we will always use
60
+ -- overlapping I/O when WinIO is enabled we return `True` here.
52
61
--
53
62
-- Since 2.7.0.0.
54
63
getNonBlock :: CSocket -> IO Bool
55
64
#if defined(mingw32_HOST_OS)
56
- -- | TODO: Query socket for async flag
65
+ # if defined(__IO_MANAGER_WINIO__)
66
+ getNonBlock _ = return False <!> return True
67
+ # else
57
68
getNonBlock _ = return False
69
+ # endif
58
70
#else
59
71
getNonBlock fd = do
60
72
flags <- c_fcntl_read fd fGetFl 0
0 commit comments