Safe Haskell | None |
---|---|
Language | Haskell2010 |
UDP networking. Uses persist
to serializie messages.
Uses a TBQueue
for outgoing messages since multiple threads are likely to
need to send messages to the socket, and: "The proper programming model is
that one Socket is handled by a single thread. If multiple threads use one
Socket concurrently, unexpected things would happen." (from
http://hackage.haskell.org/package/network-2.8.0.0/docs/Network-Socket.html)
Synopsis
- data Udp message
- runUdp :: (HasLogFunc env, Persist message, Display message) => Udp message -> RIO env ()
- sendUdp :: Udp message -> Peer -> message -> STM ()
- sinkUdpSend :: MonadIO m => Udp message -> ConduitT (Peer, message) o m ()
- sourceUdpReceive :: MonadIO m => Udp message -> ConduitT i (Peer, message) m ()
- udpFamily :: Udp message -> Family
- withUdp :: HostPreference -> PortNumber -> (Udp message -> RIO env a) -> RIO env a
Documentation
runUdp :: (HasLogFunc env, Persist message, Display message) => Udp message -> RIO env () #
Run the UDP networking (does not return). The given action will be called fro every message received.
sendUdp :: Udp message -> Peer -> message -> STM () #
Write a UDP message to the send queue. This is in STM so that you can have sending messages be in the same atomic transaction as state changes.
sinkUdpSend :: MonadIO m => Udp message -> ConduitT (Peer, message) o m () #
Sink to the UDP message send queue.
sourceUdpReceive :: MonadIO m => Udp message -> ConduitT i (Peer, message) m () #
:: HostPreference | Address of interface to bind too |
-> PortNumber | Port to bind to |
-> (Udp message -> RIO env a) | Action to run |
-> RIO env a |
Create a new Udp
with the given settings.