diff options
author | Lars Kuhtz <lars@alephcloud.com> | 2012-06-10 14:04:34 -0700 |
---|---|---|
committer | unknown <lars@lars-PC.(none)> | 2012-06-10 14:04:34 -0700 |
commit | 78eae6c6b3550fa3ad3a4289ddd385de6e75a996 (patch) | |
tree | 140133a5251645aa6f559aa2d1030cbdb0c0bec7 /Network | |
parent | 08ff21f8ce61b21a2c31be0372f91ad017790f98 (diff) |
Make Network.DNS.Resolver compile on mingw32hosts
Diffstat (limited to 'Network')
-rw-r--r-- | Network/DNS/Resolver.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Network/DNS/Resolver.hs b/Network/DNS/Resolver.hs index 7cfb6d3..f040383 100644 --- a/Network/DNS/Resolver.hs +++ b/Network/DNS/Resolver.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-| DNS Resolver and lookup functions. @@ -41,6 +42,11 @@ import Prelude hiding (lookup) import System.Random import System.Timeout +#if mingw32_HOST_OS == 1 +import Network.Socket (send) +import qualified Data.ByteString.Lazy.Char8 as LB +import Control.Monad (when) +#endif ---------------------------------------------------------------- {-| @@ -180,3 +186,11 @@ lookupRaw rlv dom typ = do if identifier hdr == seqno then Just res else Nothing + +#if mingw32_HOST_OS == 1 + -- Windows does not support sendAll in Network.ByteString.Lazy. + -- This implements sendAll with Haskell Strings. + sendAll sock bs = do + sent <- send sock (LB.unpack bs) + when (sent < fromIntegral (LB.length bs)) $ sendAll sock (LB.drop (fromIntegral sent) bs) +#endif |