Skip to content

Commit f6cf262

Browse files
Mistukekazu-yamamoto
authored andcommitted
Working on it
1 parent 298d50a commit f6cf262

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Network/Socket/Fcntl.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import qualified System.Posix.Internals
77

88
#if !defined(mingw32_HOST_OS)
99
import Network.Socket.Cbits
10+
#else
11+
# if defined(__IO_MANAGER_WINIO__)
12+
import GHC.IO.SubSystem ((<!>))
13+
# endif
1014
#endif
1115
import Network.Socket.Imports
1216

@@ -15,6 +19,7 @@ import Network.Socket.Imports
1519
setNonBlockIfNeeded :: CSocket -> IO ()
1620
setNonBlockIfNeeded fd =
1721
System.Posix.Internals.setNonBlockingFD (fromIntegral fd) True
22+
1823
-- TODO: remove fromIntegral for WinIO
1924

2025
-- | Set the close_on_exec flag on Unix.
@@ -48,13 +53,20 @@ getCloseOnExec fd = do
4853
#endif
4954

5055
-- | 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.
5261
--
5362
-- Since 2.7.0.0.
5463
getNonBlock :: CSocket -> IO Bool
5564
#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
5768
getNonBlock _ = return False
69+
# endif
5870
#else
5971
getNonBlock fd = do
6072
flags <- c_fcntl_read fd fGetFl 0

0 commit comments

Comments
 (0)