diff --git a/Network/DNS/Decode.hs b/Network/DNS/Decode.hs
--- a/Network/DNS/Decode.hs
+++ b/Network/DNS/Decode.hs
@@ -167,12 +167,11 @@
 decodeDomain = do
     pos <- getPosition
     c <- getInt8
-    if c == 0
-      then return ""
+    if c == 0 then
+        return ""
       else do
         let n = getValue c
-        if isPointer c
-          then do
+        if isPointer c then do
             d <- getInt8
             let offset = n * 256 + d
             fromMaybe (error $ "decodeDomain: " ++ show offset) <$> pop offset
diff --git a/Network/DNS/Encode.hs b/Network/DNS/Encode.hs
--- a/Network/DNS/Encode.hs
+++ b/Network/DNS/Encode.hs
@@ -4,6 +4,7 @@
   , composeQuery
   ) where
 
+import qualified Blaze.ByteString.Builder as BB (toByteString, fromWrite, writeInt16be)
 import qualified Data.ByteString.Lazy.Char8 as BL (ByteString)
 import qualified Data.ByteString.Char8 as BS (length, null, break, drop)
 import Network.DNS.StateBinary
@@ -104,9 +105,16 @@
       , putInt16 (typeToInt rrtype)
       , put16 1
       , putInt32 rrttl
-      , putInt16 rdlen
-      , encodeRDATA rdata
+      , rlenRDATA
       ]
+  where
+    -- Encoding rdata without using rdlen
+    rlenRDATA = do
+        addPositionW 2 -- "simulate" putInt16
+        rDataWrite <- encodeRDATA rdata
+        let rdataLength = fromIntegral . BS.length . BB.toByteString . BB.fromWrite $ rDataWrite
+        let rlenWrite = BB.writeInt16be rdataLength
+        return rlenWrite +++ return rDataWrite
 
 encodeRDATA :: RDATA -> SPut
 encodeRDATA rd = case rd of
diff --git a/Network/DNS/Resolver.hs b/Network/DNS/Resolver.hs
--- 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 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
 ----------------------------------------------------------------
 
 {-|
@@ -152,9 +158,7 @@
 lookup rlv dom typ = (>>= toRDATA) <$> lookupRaw rlv dom typ
   where
     {- CNAME hack
-    dom' = if "." `isSuffixOf` dom
-           then dom
-           else dom ++ "."
+    dom' = if "." `isSuffixOf` dom then dom else dom ++ "."
     correct r = rrname r == dom' && rrtype r == typ
     -}
     correct r = rrtype r == typ
@@ -177,6 +181,15 @@
     q = makeQuestion dom typ
     check seqno res = do
         let hdr = header res
-        if identifier hdr == seqno
-            then Just res
-            else Nothing
+        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
diff --git a/dns.cabal b/dns.cabal
--- a/dns.cabal
+++ b/dns.cabal
@@ -1,5 +1,5 @@
 Name:                   dns
-Version:                0.3.3
+Version:                0.3.4
 Author:                 Kazu Yamamoto <kazu@iij.ad.jp>
 Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp>
 License:                BSD3
@@ -11,10 +11,7 @@
 Build-Type:             Simple
 Extra-Source-Files:     Test.hs, TestProtocol.hs
 library
-  if impl(ghc >= 6.12)
-    GHC-Options:        -Wall -fno-warn-unused-do-bind
-  else
-    GHC-Options:        -Wall
+  GHC-Options:          -Wall
   Exposed-Modules:      Network.DNS
                         Network.DNS.Lookup
                         Network.DNS.Resolver
@@ -24,19 +21,34 @@
   Other-Modules:        Network.DNS.Internal
                         Network.DNS.StateBinary
   if impl(ghc >= 7)
-    Build-Depends:      base >= 4 && < 5,
-                        binary, iproute >= 1.2.4,
-                        containers, mtl, bytestring, random,
-                        network >= 2.3, blaze-builder,
-                        attoparsec, enumerator, attoparsec-enumerator,
-                        network-enumerator
+    Build-Depends:      base >= 4 && < 5
+                      , attoparsec
+                      , attoparsec-enumerator
+                      , binary
+                      , blaze-builder
+                      , bytestring
+                      , containers
+                      , enumerator
+                      , iproute >= 1.2.4
+                      , mtl
+                      , network >= 2.3
+                      , network-enumerator
+                      , random
   else
-    Build-Depends:      base >= 4 && < 5,
-                        binary, iproute >= 1.2.4,
-                        containers, mtl, bytestring, random,
-                        network, network-bytestring, blaze-builder,
-                        attoparsec, enumerator, attoparsec-enumerator,
-                        network-enumerator
+    Build-Depends:      base >= 4 && < 5
+                      , attoparsec
+                      , attoparsec-enumerator
+                      , binary
+                      , blaze-builder
+                      , bytestring
+                      , containers
+                      , enumerator
+                      , iproute >= 1.2.4
+                      , mtl
+                      , network
+                      , network-bytestring
+                      , network-enumerator
+                      , random
 Source-Repository head
   Type:                 git
   Location:             git://github.com/kazu-yamamoto/dns.git
