RosettaCodeData/Task/DNS-query/Haskell/dns-query-1.hs
2023-07-01 13:44:08 -04:00

16 lines
464 B
Haskell

module Main where
import Network.Socket
getWebAddresses :: HostName -> IO [SockAddr]
getWebAddresses host = do
results <- getAddrInfo (Just defaultHints) (Just host) (Just "http")
return [ addrAddress a | a <- results, addrSocketType a == Stream ]
showIPs :: HostName -> IO ()
showIPs host = do
putStrLn $ "IP addresses for " ++ host ++ ":"
addresses <- getWebAddresses host
mapM_ (putStrLn . (" "++) . show) addresses
main = showIPs "www.kame.net"