network-multicast-0.3.2: Simple multicast library

Copyright | (c) Audrey Tang 2008
License | MIT License
Maintainer | audreyt@audreyt.org
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Network.Multicast

Contents

- Simple sending and receiving
- Additional Socket operations
- Socket options

Description

The Network.Multicast module is for sending UDP datagrams over multicast (class D) addresses.

Synopsis

- multicastSender :: HostName -> PortNumber -> IO (Socket, SockAddr)
- multicastReceiver :: HostName -> PortNumber -> IO Socket
- addMembership :: Socket -> HostName -> Maybe HostName -> IO ()
- dropMembership :: Socket -> HostName -> Maybe HostName -> IO ()
- setLoopbackMode :: Socket -> LoopbackMode -> IO ()
- setTimeToLive :: Socket -> TimeToLive -> IO ()
- setInterface :: Socket -> HostName -> IO ()
- type TimeToLive = Int
- type LoopbackMode = Bool
- enableLoopback :: LoopbackMode
- noLoopback :: LoopbackMode

# Simple sending and receiving

multicastSender :: HostName -> PortNumber -> IO (Socket, SockAddr) Source #

Calling `multicastSender` creates a client side UDP socket for sending multicast datagrams to the specified host and port.

Minimal example:

    import Network.Socket
    import Network.Multicast
    main = withSocketsDo $ do
        (sock, addr) <- multicastSender "224.0.0.99" 9999
        let loop = do
            sendTo sock "Hello, world" addr
            loop in loop

multicastReceiver :: HostName -> PortNumber -> IO Socket Source #

Calling `multicastReceiver` creates and binds a UDP socket for listening multicast datagrams on the specified host and port.

Minimal example:

    import Network.Socket
    import Network.Multicast
    main = withSocketsDo $ do
        sock <- multicastReceiver "224.0.0.99" 9999
        let loop = do
            (msg, _, addr) <- recvFrom sock 1024
            print (msg, addr) in loop

# Additional Socket operations

addMembership :: Socket -> HostName -> Maybe HostName -> IO () Source #

Make the socket listen on multicast datagrams sent by the specified `HostName`.

dropMembership :: Socket -> HostName -> Maybe HostName -> IO () Source #

Stop the socket from listening on multicast datagrams sent by the specified `HostName`.

setLoopbackMode :: Socket -> LoopbackMode -> IO () Source #

Enable or disable the loopback mode on a socket created by `multicastSender`. Loopback is enabled by default; disabling it may improve performance a little bit.

setTimeToLive :: Socket -> TimeToLive -> IO () Source #

Set the Time-to-Live of the multicast.

setInterface :: Socket -> HostName -> IO () Source #

Set the outgoing interface address of the multicast.

# Socket options

type TimeToLive = Int Source #

type LoopbackMode = Bool Source #

enableLoopback :: LoopbackMode Source #

noLoopback :: LoopbackMode Source #