streamly-network-tcp: TCP connections as Streamly streams, for clients and servers

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

The ground under the Streamly network libraries of this family: opening a TCP connection to a host by its name, listening, serving each client in a thread of its own, and a transport, the pair of a way to send byte arrays and a stream of those received, that protocols are written against so that they run over TCP, TLS or anything else.


[Skip to Readme]

Modules

  • Streamly
    • External
      • Network
        • Streamly.External.Network.TCP

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 (>=0.11.1 && <0.12), 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:29:02Z
Category Network, Streamly
Home page https://github.com/GuillaumedeVolpiano/streamly-network-tcp
Source repo head: git clone https://github.com/GuillaumedeVolpiano/streamly-network-tcp.git
Distributions
Reverse Dependencies 3 direct, 3 indirect [details]
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-tcp-0.1.0.0

[back to package description]

streamly-network-tcp

TCP connections for Streamly, for clients and for servers, over the network package. It is the ground under the network libraries of this family (streamly-http, streamly-websockets, streamly-network-tls).

{-# LANGUAGE OverloadedRecordDot #-}

import Control.Exception (bracket)
import Network.Socket (close)
import Streamly.Data.Fold (drainMapM)
import Streamly.Data.Stream (fold)
import Streamly.External.Network.TCP (Transport (..), listen, serveConnections,
                                      socketTransport)

-- Send back to each client what it sends.
main :: IO ()
main = bracket (listen "127.0.0.1" 7000) close $ \listener ->
  serveConnections listener $ \peer ->
    let transport = socketTransport peer
     in fold (drainMapM transport.send) transport.receive

What it gives

  • Transport: a way to send byte arrays and the stream of those received. Protocols written against it run over plain TCP (socketTransport), over TLS, or over anything else that gives the two.
  • connect and connectWithin: a connection to a host by its name, to the first of its addresses that accepts it, within a time if asked.
  • listen and serveConnections: a listening socket, and each client served in a thread of its own.
  • opened: a connected socket as a transport and what closes it, for the connections that outlive a function.