udp-conduit: Simple fire-and-forget conduit UDP wrappers

[ conduit, data, library ] [ Propose Tags ]

`udp-conduit` provides simple wrappers to get fire-and-forget UDP sinks and sources.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.2, 0.1.0.4
Dependencies base (>=4.7 && <5), chunked-data, conduit-combinators, mono-traversable, network [details]
License ISC
Copyright (c) 2016 kqr
Author kqr
Maintainer k@rdw.se
Category Data, Conduit
Home page https://github.com/kqr/udp-conduit#readme
Source repo head: git clone https://github.com/kqr/udp-conduit
Uploaded by kqr at 2016-10-21T07:41:09Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2122 total (9 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-10-21 [all 1 reports]

Readme for udp-conduit-0.1.0.4

[back to package description]

udp-conduit

Simple fire-and-forget style conduit parts (sources/sinks) for UDP traffic.

Here's an example that sends a message to UDP port 8888 on localhost:

import Conduit
import Conduit.UDP
import Data.Text

message :: Text
message = "hello, world!\n"

main :: IO ()
main =
    runConduitRes (yield message .| encodeUtf8C .| udpSink "127.0.0.1" 8888)

Here's an example where we continuously receive messages on port 5666 on localhost:

import Conduit
import Conduit.UDP

main :: IO ()
main =
    runConduitRes (udpSource "127.0.0.1" 5666 .| decodeUtf8C .| stdoutC)

Now, here's an example where we receive messages on port 8001, transform them to upper-case, and then send them on to port 8002.

import Conduit
import Conduit.UDP
import Data.Char (toUpper)

main :: IO ()
main =
    runConduitRes (udpSource "127.0.0.1" 8001 .| omapCE toUpper .| udpSink "127.0.0.1" 8002)

Fun, huh? And simple!