-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Recvmsg and sendmsg bindings. -- @package network-msg @version 0.5 module Network.Socket.Msg.CMsg data CMsg CMsg :: !Int -> !Int -> !ByteString -> CMsg cmsgLevel :: CMsg -> !Int cmsgType :: CMsg -> !Int cmsgData :: CMsg -> !ByteString -- | Class for binary structures that can be used as control messages -- (cmsg(3)). -- -- Complete definition requires for a type to be an instance of Binary -- class, as well as to provide getCMsgLevel and getCMsgType methods. -- -- Note that the argument of getCMsgLevel and getCMsgType methods should -- not be used as it might be undefined. class Binary a => CMsgable a where toCMsg x = CMsg {cmsgLevel = getCMsgLevel x, cmsgType = getCMsgType x, cmsgData = toStrict $ encode x} fromCMsg cmsg = case decodeOrFail (fromStrict $ cmsgData cmsg) of { Left _ -> Nothing Right (_, _, x) -> Just x } getCMsgLevel :: CMsgable a => a -> Int getCMsgType :: CMsgable a => a -> Int toCMsg :: CMsgable a => a -> CMsg fromCMsg :: CMsgable a => CMsg -> Maybe a -- | Filter specific kind of control messages. -- -- Example: filterCMsgs (undefined :: IpPktInfo) cmsgs filterCMsgs :: CMsgable a => a -> [CMsg] -> [CMsg] data IpPktInfo IpPktInfo :: !Word32 -> !HostAddress -> !HostAddress -> IpPktInfo ipi_ifindex :: IpPktInfo -> !Word32 ipi_spec_dst :: IpPktInfo -> !HostAddress ipi_addr :: IpPktInfo -> !HostAddress instance Show IpPktInfo instance CMsgable IpPktInfo instance Binary IpPktInfo instance Show CMsg module Network.Socket.Msg data CMsg CMsg :: !Int -> !Int -> !ByteString -> CMsg cmsgLevel :: CMsg -> !Int cmsgType :: CMsg -> !Int cmsgData :: CMsg -> !ByteString -- | Class for binary structures that can be used as control messages -- (cmsg(3)). -- -- Complete definition requires for a type to be an instance of Binary -- class, as well as to provide getCMsgLevel and getCMsgType methods. -- -- Note that the argument of getCMsgLevel and getCMsgType methods should -- not be used as it might be undefined. class Binary a => CMsgable a where toCMsg x = CMsg {cmsgLevel = getCMsgLevel x, cmsgType = getCMsgType x, cmsgData = toStrict $ encode x} fromCMsg cmsg = case decodeOrFail (fromStrict $ cmsgData cmsg) of { Left _ -> Nothing Right (_, _, x) -> Just x } getCMsgLevel :: CMsgable a => a -> Int getCMsgType :: CMsgable a => a -> Int toCMsg :: CMsgable a => a -> CMsg fromCMsg :: CMsgable a => CMsg -> Maybe a -- | Filter specific kind of control messages. -- -- Example: filterCMsgs (undefined :: IpPktInfo) cmsgs filterCMsgs :: CMsgable a => a -> [CMsg] -> [CMsg] -- | Sends the data contained in the bytestring to the specified address. -- The last argument is a list of control parameters (see cmsg(3) for -- details). sendMsg :: Socket -> ByteString -> SockAddr -> [CMsg] -> IO () -- | Receive data and put it into a bytestring. recvMsg :: Socket -> Int -> IO (ByteString, SockAddr, [CMsg])