streamly-network-udp: UDP datagrams as Streamly streams

[ bsd3, library, network, streamly ] [ Propose Tags ] [ Report a vulnerability ]

UDP sockets for Streamly, over the network package: the datagrams received are a stream, each with its sender; datagrams are sent one by one or through a fold. With the broadcast option and, for IPv4, multicast groups.


[Skip to Readme]

Modules

  • Streamly
    • External
      • Network
        • Streamly.External.Network.UDP

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.19 && <4.22), network (>=3.2 && <3.3), streamly-bytestring (>=0.2.3 && <0.3), streamly-core (>=0.3.3 && <0.4) [details]
Tested with ghc ==9.8.4 || ==9.10.3 || ==9.12.4
License BSD-3-Clause
Author Xavier Dectot
Maintainer Xavier Dectot <xavier@wheredoibegin.fr>
Uploaded by GdeVolpiano at 2026-11-28T09:43:14Z
Category Network, Streamly
Home page https://github.com/GuillaumedeVolpiano/streamly-network-udp
Source repo head: git clone https://github.com/GuillaumedeVolpiano/streamly-network-udp.git
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-11-28 [all 1 reports]

Readme for streamly-network-udp-0.1.0.0

[back to package description]

streamly-network-udp

UDP sockets for Streamly, over the network package. The datagrams received are a stream, each with the address of its sender; datagrams are sent one by one or through a fold.

import Network.Socket (SockAddr (SockAddrInet), tupleToHostAddress)
import Streamly.Data.Array (fromList)
import Streamly.Data.Stream (toList)
import Streamly.External.Network.UDP (anyAddress, datagramsWithin, sendTo,
                                      socketAt, withSocket)

-- Ask, and collect the answers that come within a second.
main :: IO ()
main = withSocket (socketAt anyAddress) $ \socket -> do
  sendTo socket (SockAddrInet 9003 (tupleToHostAddress (192, 0, 2, 1))) (fromList [1, 2, 3])
  answers <- toList (datagramsWithin 1000000 socket)
  print (map fst answers)

What it gives

  • withSocket: a socket bound to an address, with reuseAddress and broadcast as options.
  • datagrams: the datagrams received, without end; datagramsWith to give each less room; datagramsWithin for those that come within a time.
  • sendTo, and the folds write (one address) and writeTo (an address with each datagram).
  • For IPv4 multicast: joinGroup, leaveGroup, setMulticastTTL, setMulticastLoopback.

Limits of this version

  • Unix only: the multicast options are set as Unix systems expect them.
  • Multicast groups are IPv4 only. Sockets can be IPv6.
  • No connected sockets: every datagram names its destination.