From 78eae6c6b3550fa3ad3a4289ddd385de6e75a996 Mon Sep 17 00:00:00 2001 From: Lars Kuhtz Date: Sun, 10 Jun 2012 14:04:34 -0700 Subject: Make Network.DNS.Resolver compile on mingw32hosts --- Network/DNS/Resolver.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- cgit v1.2.3