The udp-conduit package

[ Tags: conduit, data, library ] [ Propose Tags ]

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


[Skip to Readme]

Properties

Versions 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 repository head: git clone https://github.com/kqr/udp-conduit
Uploaded Fri Oct 21 07:41:09 UTC 2016 by kqr
Distributions NixOS:0.1.0.4
Downloads 229 total (66 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-10-21 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


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!