diff options
-rw-r--r-- | Presence/GetHostByAddr.hs | 14 |
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 | |||
6 | import Foreign.C.Types | 6 | import Foreign.C.Types |
7 | import Foreign.Storable (Storable(..)) | 7 | import Foreign.Storable (Storable(..)) |
8 | import Foreign.Marshal.Utils (with) | 8 | import Foreign.Marshal.Utils (with) |
9 | import Foreign.Marshal.Alloc | ||
9 | import Control.Concurrent | 10 | import Control.Concurrent |
10 | import System.IO.Unsafe | 11 | import System.IO.Unsafe |
11 | import System.IO.Error (ioeSetErrorString, mkIOError) | 12 | import 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 | {- | 59 | getHostByAddr (SockAddrInet6 port flow (a,b,c,d) scope) = do |
59 | getHostByAddr (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 | ||
68 | foreign import ccall safe "gethostbyaddr" | 72 | foreign import ccall safe "gethostbyaddr" |