hosc-0.17: 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
- upd_send_packet :: UDP -> Packet -> IO ()
- udp_recv_packet :: UDP -> IO Packet
- udp_close :: UDP -> IO ()
- with_udp :: IO UDP -> (UDP -> IO t) -> IO t
- udp_socket :: (Socket -> SockAddr -> IO ()) -> String -> Int -> IO UDP
- set_udp_opt :: SocketOption -> Int -> UDP -> IO ()
- get_udp_opt :: SocketOption -> UDP -> IO Int
- openUDP :: String -> Int -> IO UDP
- udpServer :: String -> Int -> IO UDP
- udp_server :: Int -> IO UDP
- sendTo :: UDP -> Packet -> SockAddr -> IO ()
- recvFrom :: UDP -> IO (Packet, SockAddr)

# Documentation

data UDP Source #

The UDP transport handle data type.

Constructors

UDP |

Fields

- udpSocket :: Socket

#### Instances

Instances details

Transport UDP Source # | `UDP` is an instance of `Transport`.
Instance details Defined in Sound.OSC.Transport.FD.UDP Methods sendPacket :: UDP -> Packet -> 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.

upd_send_packet :: UDP -> Packet -> IO () Source #

Send packet over UDP.

udp_recv_packet :: UDP -> IO Packet Source #

Receive packet over UDP.

udp_close :: UDP -> IO () Source #

Close UDP.

with_udp :: IO UDP -> (UDP -> IO t) -> IO t Source #

Bracket UDP communication.

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

Create and initialise UDP socket.

set_udp_opt :: SocketOption -> Int -> UDP -> IO () Source #

Set option, ie. `Broadcast` or `RecvTimeOut`.

get_udp_opt :: SocketOption -> UDP -> IO Int Source #

Get option.

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

Make a `UDP` connection.

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

Trivial `UDP` server socket.

    import Control.Concurrent

    let t0 = udpServer "127.0.0.1" 57300
    forkIO (FD.withTransport t0 (\fd -> forever (FD.recvMessage fd >>= print)))

    let t1 = openUDP "127.0.0.1" 57300
    FD.withTransport t1 (\fd -> FD.sendMessage fd (Packet.message "/n" []))

udp_server :: Int -> IO UDP Source #

Variant of `udpServer` that doesn't require the host address.

sendTo :: UDP -> Packet -> SockAddr -> IO () Source #

Send variant to send to specified address.

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

Recv variant to collect message source address.