gini-network-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Gini.Network.Udp

Description

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

Documentation

data Udp message #

Configuration used for UDP networking

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 () #

udpFamily :: Udp message -> Family #

Address family of UDP socket.

withUdp #

Arguments

:: 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.