summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Presence/GetHostByAddr.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Presence/GetHostByAddr.hs b/Presence/GetHostByAddr.hs
index 25ebd7c2..45bca5e9 100644
--- a/Presence/GetHostByAddr.hs
+++ b/Presence/GetHostByAddr.hs
@@ -6,6 +6,7 @@ import Foreign.Ptr
6import Foreign.C.Types 6import Foreign.C.Types
7import Foreign.Storable (Storable(..)) 7import Foreign.Storable (Storable(..))
8import Foreign.Marshal.Utils (with) 8import Foreign.Marshal.Utils (with)
9import Foreign.Marshal.Alloc
9import Control.Concurrent 10import Control.Concurrent
10import System.IO.Unsafe 11import System.IO.Unsafe
11import System.IO.Error (ioeSetErrorString, mkIOError) 12import System.IO.Error (ioeSetErrorString, mkIOError)
@@ -55,14 +56,17 @@ getHostByAddr (SockAddrInet port addr ) = do
55 throwNoSuchThingIfNull "getHostByAddr" "no such host entry" 56 throwNoSuchThingIfNull "getHostByAddr" "no such host entry"
56 $ trySysCall $ c_gethostbyaddr ptr_addr (fromIntegral (sizeOf addr)) (packFamily family) 57 $ trySysCall $ c_gethostbyaddr ptr_addr (fromIntegral (sizeOf addr)) (packFamily family)
57 >>= peek 58 >>= peek
58{- 59getHostByAddr (SockAddrInet6 port flow (a,b,c,d) scope) = do
59getHostByAddr (SockAddrInet6 port flow addr scope) = do
60 let family = AF_INET6 60 let family = AF_INET6
61 with addr $ \ ptr_addr -> withLock $ do 61 allocaBytes 16 $ \ ptr_addr -> do
62 pokeElemOff ptr_addr 0 a
63 pokeElemOff ptr_addr 1 b
64 pokeElemOff ptr_addr 2 c
65 pokeElemOff ptr_addr 3 d
66 withLock $ do
62 throwNoSuchThingIfNull "getHostByAddr" "no such host entry" 67 throwNoSuchThingIfNull "getHostByAddr" "no such host entry"
63 $ trySysCall $ c_gethostbyaddr ptr_addr (fromIntegral (sizeOf addr)) (packFamily family) 68 $ trySysCall $ c_gethostbyaddr ptr_addr 16 (packFamily family)
64 >>= peek 69 >>= peek
65-}
66 70
67 71
68foreign import ccall safe "gethostbyaddr" 72foreign import ccall safe "gethostbyaddr"