Anonymous avatar Anonymous committed abec7d7

getAddrInfo example

Comments (0)

Files changed (2)

 import Network.DNSSD.ServicesUtils
 import Control.Concurrent
 import Foreign.Ptr
-import Network.Socket
+import Network.Socket hiding (getAddrInfo) -- TODO
 import Control.Monad (forever, forM_, liftM)
 import Data.Maybe(maybe)
 import System.Exit
     , ("Open NAT"                   , openNAT     >>= runServiceFor 5   )
     , ("Browse all services"        , browseAll   >>= runServiceFor 5   )
     , ("Enumerate domains"          , enumDomains >>= runServiceFor 5   )
+    , ("Get address info"           , getAddressInfo >>= runServiceFor 5)
     ]
 
 menuItemsWithChars = zip ['1'..] menuItems
     []
     DNSServiceInterfaceIndexAny 
 
+getAddressInfo =
+    getAddrInfo [DNSServiceProtocol_IPv4] "www.google.com" print [] DNSServiceInterfaceIndexAny
+
 enumDomains = enumerateDomainsS (print ) [DNSServiceFlagsBrowseDomains] DNSServiceInterfaceIndexAny 
 
 main :: IO ()

Network/DNSSD/Services.chs

-{-# LANGUAGE DataKinds #-}
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# LANGUAGE TypeFamilies #-}
 module Network.DNSSD.Services -- {{{
 import Network.DNSSD.StringLike
 import Network.DNSSD.Error
 
-import Data.Word
 import Data.ByteString (packCStringLen)
 -- }}}
 #define _DNS_SD_LIBDISPATCH 0
     t  -- hostname
     SockAddr
     Int  -- ttl
+    deriving Show
 
 data RegisterRecordReply = RegisterRecordRepy Flags DNSRecordRef
 -- }}}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.