Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Osc over Udp implementation.
Synopsis
- newtype Udp = Udp {}
- udpPort :: Integral n => Udp -> IO n
- udp_send_data :: Udp -> ByteString -> IO ()
- udp_sendAll_data :: Udp -> ByteString -> IO ()
- udp_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_send_data :: Udp -> ByteString -> IO () Source #
Send data over Udp using send
.
udp_sendAll_data :: Udp -> ByteString -> IO () Source #
Send data over Udp using sendAll
.
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 >> print "Received message, continuing"))) killThread t0
let u1 = openUdp "127.0.0.1" 57300 Fd.withTransport u1 (\fd -> Fd.sendMessage fd (Packet.message "/n" []))