udp-streaming-0.1.0.0: Simple fire-and-forget udp Streaming components modelled after udp-conduit

Copyright(c) 2018 Mihai Giurgeanu
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streaming.UDP

Description

 

Synopsis

Documentation

fromUDP Source #

Arguments

:: MonadResource m 
=> String

address to bind to

-> PortNumber

port number to bind to

-> Int

maximum size of a datagram

-> Stream (Of (ByteString, SockAddr)) m r 

Fire-and-forget style UDP source. It will attempt to listen on the specified interface and port, and if it succeeds it can read contents being sent to that interface and port. It streams a pair of (message, source-address) allowing the downstream to know who sent the message.

fromSocket Source #

Arguments

:: MonadIO m 
=> Socket

the socket

-> Int

max lenght of a datagram

-> Stream (Of (ByteString, SockAddr)) m r

the resulting stream of messages

Stream the contents of a bound Socket as binary data. Note that this function will not automatically close the Socket when processing completes, since it did not acquire the Socket in the first place.

fromIOSocket Source #

Arguments

:: MonadResource m 
=> IO Socket

the IO action to create the UDP socket

-> Int

max length of a datagram

-> Stream (Of (ByteString, SockAddr)) m r

the resulting stream of messages

An alternative to fromSocket. Instead of taking a pre-bound Socket, it takes an action that opens and binds a Socket, so that it can open it only when needed and close it as soon as possible.

toUDP :: MonadResource m => String -> PortNumber -> Stream (Of ByteString) m r -> m r Source #

gets an ip adress, a port and stream of strict ByteStrings and sends all the ByteStrings to UDP socket

toSocket :: MonadIO m => Socket -> Stream (Of ByteString) m r -> m r Source #

Stream all incoming data to the given connected Socket. Note that this function will not automatically close the Socket when processing completes.

toIOSocket :: MonadResource m => IO Socket -> Stream (Of ByteString) m r -> m r Source #

An alternative to toSocket. Instead of taking a pre-opened Socket, it takes an action that returns a connected Socket , so that it can open it only when needed and close it as soon as possible.