hosc-0.15: Haskell Open Sound Control

Safe Haskell | None
Language | Haskell98

Sound.OSC.Transport.FD.UDP

Description

OSC over UDP implementation.

Synopsis

- data UDP = UDP {
  - udpSocket :: Socket
  }
- udpPort :: Integral n => UDP -> IO n
- udp_socket :: (Socket -> SockAddr -> IO ()) -> String -> Int -> IO UDP
- openUDP :: String -> Int -> IO UDP
- udpServer :: String -> Int -> IO UDP
- sendTo :: OSC o => UDP -> o -> SockAddr -> IO ()
- recvFrom :: UDP -> IO (Packet, SockAddr)

# Documentation

data UDP Source #

The UDP transport handle data type.

Constructors

UDP |

Fields

- udpSocket :: Socket

Instances

Transport UDP Source # |
Methods sendOSC :: OSC o => UDP -> o -> IO () Source # recvPacket :: UDP -> IO Packet Source # close :: UDP -> IO () Source #

udpPort :: Integral n => UDP -> IO n Source #

Return the port number associated with the UDP socket.

udp_socket :: (Socket -> SockAddr -> IO ()) -> String -> Int -> IO UDP Source #

Create and initialise UDP socket.

openUDP :: String -> Int -> IO UDP Source #

Make a `UDP` connection.

    let t = openUDP "127.0.0.1" 57110
    in withTransport t (\fd -> recvT 0.5 fd >>= print)

udpServer :: String -> Int -> IO UDP Source #

Trivial `UDP` server socket.

    import Control.Concurrent

    let {f fd = forever (recvMessage fd >>= print)
        ;t = udpServer "127.0.0.1" 57300}
    in void (forkIO (withTransport t f))

    let t = openUDP "127.0.0.1" 57300
    in withTransport t (\fd -> sendMessage fd (message "/n" []))

sendTo :: OSC o => UDP -> o -> SockAddr -> IO () Source #

Send variant to send to specified address.

recvFrom :: UDP -> IO (Packet, SockAddr) Source #

Recv variant to collect message source address.