File: receiver.hs

package info (click to toggle)
haskell-network-multicast 0.3.2-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 84 kB
  • sloc: haskell: 32; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 388 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
import Network.Socket (withSocketsDo)
import qualified Data.ByteString.Char8 as C
import Network.Socket.ByteString (recvFrom)
import Network.Multicast

main :: IO ()
main = withSocketsDo $ do
    sock <- multicastReceiver "224.0.0.99" 9999
    let loop = do
        (msg, addr) <- recvFrom sock 1024
        putStrLn $ "Recv [" ++ show addr ++ "]: " ++ C.unpack msg
        loop
    loop