Safe Haskell | None |
---|---|
Language | Haskell2010 |
OSC over UDP implementation.
Synopsis
- data UDP = UDP {}
- 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
The UDP transport handle data type.
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.
udpServer :: String -> Int -> IO UDP Source #
Trivial UDP
server socket.
import Control.Concurrent
let u0 = udpServer "127.0.0.1" 57300 t0 <- forkIO (FD.withTransport u0 (\fd -> forever (FD.recvMessage fd >>= print)))
let u1 = openUDP "127.0.0.1" 57300 FD.withTransport u1 (\fd -> FD.sendMessage fd (Packet.message "/n" []))