diff --git a/Network/Socket.hsc b/Network/Socket.hsc
--- a/Network/Socket.hsc
+++ b/Network/Socket.hsc
@@ -1729,8 +1729,10 @@
 
 unpackBits :: Bits b => [(a, b)] -> b -> [a]
 
-unpackBits [] 0    = []
-unpackBits [] r    = error ("unpackBits: unhandled bits set: " ++ show r)
+-- Be permissive and ignore unknown bit values. At least on OS X,
+-- getaddrinfo returns an ai_flags field with bits set that have no
+-- entry in <netdb.h>.
+unpackBits [] _    = []
 unpackBits ((k,v):xs) r
     | r .&. v /= 0 = k : unpackBits xs (r .&. complement v)
     | otherwise    = unpackBits xs r
diff --git a/Network/Socket/Internal.hsc b/Network/Socket/Internal.hsc
--- a/Network/Socket/Internal.hsc
+++ b/Network/Socket/Internal.hsc
@@ -530,6 +530,8 @@
     -> IO a             -- ^ the 'IO' operation to be executed
     -> IO ()
 
+{-# SPECIALIZE throwSocketErrorIfMinus1_ :: String -> IO CInt -> IO () #-}
+
 -- | Throw an 'IOError' corresponding to the current socket error if
 -- the IO action returns a result of @-1@, but retries in case of an
 -- interrupted operation.
@@ -538,6 +540,8 @@
     -> IO a             -- ^ the 'IO' operation to be executed
     -> IO a
 
+{-# SPECIALIZE throwSocketErrorIfMinus1Retry :: String -> IO CInt -> IO CInt #-}
+
 -- | Throw an 'IOError' corresponding to the current socket error if
 -- the IO action returns a result of @-1@, but retries in case of an
 -- interrupted operation.  Checks for operations that would block and
@@ -548,6 +552,9 @@
                         --   immediate retry would block
     -> IO a             -- ^ the 'IO' operation to be executed
     -> IO a
+
+{-# SPECIALIZE throwSocketErrorIfMinus1RetryMayBlock
+        :: String -> IO b -> IO CInt -> IO CInt #-}
 
 #if defined(__GLASGOW_HASKELL__) && (!defined(HAVE_WINSOCK_H) || defined(cygwin32_HOST_OS))
 
diff --git a/network.cabal b/network.cabal
--- a/network.cabal
+++ b/network.cabal
@@ -1,5 +1,5 @@
 name:           network
-version:        2.2.1
+version:        2.2.1.1
 license:        BSD3
 license-file:   LICENSE
 maintainer:     Johan Tibell <johan.tibell@gmail.com>
