packages feed

network-multicast 0.0.11 → 0.0.12

raw patch · 2 files changed

+13/−11 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Network.Multicast: addMembership :: Socket -> HostName -> IO ()
+ Network.Multicast: addMembership :: Socket -> HostName -> Maybe HostName -> IO ()
- Network.Multicast: dropMembership :: Socket -> HostName -> IO ()
+ Network.Multicast: dropMembership :: Socket -> HostName -> Maybe HostName -> IO ()

Files

network-multicast.cabal view
@@ -1,5 +1,5 @@ name:               network-multicast-version:            0.0.11+version:            0.0.12 copyright:          2008-2014 Audrey Tang license:            PublicDomain license-file:       LICENSE
src/Network/Multicast.hsc view
@@ -88,9 +88,8 @@ #endif     setup :: Socket -> IO Socket     setup sock = do-      (addrInfo:_) <- getAddrInfo Nothing (Just host) (Just $ show port)-      addMembership sock host-      bindSocket sock $ addrAddress addrInfo+      bindSocket sock $ SockAddrInet port iNADDR_ANY+      addMembership sock host Nothing       return sock  doSetSocketOption :: Storable a => CInt -> Socket -> a -> IO CInt@@ -118,23 +117,26 @@     doSetSocketOption _IP_MULTICAST_IF sock addr  -- | Make the socket listen on multicast datagrams sent by the specified 'HostName'.-addMembership :: Socket -> HostName -> IO ()-addMembership s = maybeIOError "addMembership" . doMulticastGroup _IP_ADD_MEMBERSHIP s+addMembership :: Socket -> HostName -> Maybe HostName -> IO ()+addMembership s host = maybeIOError "addMembership" . doMulticastGroup _IP_ADD_MEMBERSHIP s host  -- | Stop the socket from listening on multicast datagrams sent by the specified 'HostName'.-dropMembership :: Socket -> HostName -> IO ()-dropMembership s = maybeIOError "dropMembership" . doMulticastGroup _IP_DROP_MEMBERSHIP s+dropMembership :: Socket -> HostName -> Maybe HostName -> IO ()+dropMembership s host = maybeIOError "dropMembership" . doMulticastGroup _IP_DROP_MEMBERSHIP s host  maybeIOError :: String -> IO CInt -> IO () maybeIOError name f = f >>= \err -> case err of     0 -> return ()     _ -> ioError (errnoToIOError name (Errno (fromIntegral err)) Nothing Nothing) -doMulticastGroup :: CInt -> Socket -> HostName -> IO CInt-doMulticastGroup flag (MkSocket s _ _ _ _) host = allocaBytes #{size struct ip_mreq} $ \mReqPtr -> do+doMulticastGroup :: CInt -> Socket -> HostName -> Maybe HostName -> IO CInt+doMulticastGroup flag (MkSocket s _ _ _ _) host local = allocaBytes #{size struct ip_mreq} $ \mReqPtr -> do     addr <- inet_addr host+    iface <- case local of+        Nothing -> return (#{const INADDR_ANY} `asTypeOf` addr)+        Just loc -> inet_addr loc     #{poke struct ip_mreq, imr_multiaddr} mReqPtr addr-    #{poke struct ip_mreq, imr_interface} mReqPtr (#{const INADDR_ANY} `asTypeOf` addr)+    #{poke struct ip_mreq, imr_interface} mReqPtr iface     c_setsockopt s _IPPROTO_IP flag (castPtr mReqPtr) (#{size struct ip_mreq})  #ifdef mingw32_HOST_OS