HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulestreamly-0.10.1Haskell2010

Streamly.Internal.Network.Inet.TCP

Combinators to build Inet/TCP clients and servers.

  • 24 values
  • Packagestreamly-0.10.1
  • Exports24
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTCP.hs

Setup

0 declarations

To execute the code examples provided in this module in ghci, please run the following commands first.

Example1 expression
:m
Example2 expressions
import qualified Streamly.Data.Unfold as Unfoldimport qualified Streamly.Network.Inet.TCP as TCP

TCP Servers

0 declarations

Streams

valueaccept :: MonadIO m => PortNumber -> Stream m Socket
#

Start a TCP stream server that binds on the IPV4 address 0.0.0.0 and listens for TCP connections from remote hosts on the specified server port. The server generates a stream of connected sockets.

Example1 expression
accept = TCP.acceptOnAddr (0,0,0,0)

Pre-release

Like accept but binds on the localhost IPv4 address 127.0.0.1. The server can only be accessed from the local host, it cannot be accessed from other hosts on the network.

Example1 expression
acceptLocal = TCP.acceptOnAddr (127,0,0,1)

Pre-release

Unfolds

Like acceptorOnAddr but binds on the IPv4 address 0.0.0.0 i.e. on all IPv4 addresses/interfaces of the machine and listens for TCP connections on the specified port.

Example1 expression
acceptor = Unfold.first (0,0,0,0) TCP.acceptorOnAddr

Like acceptor but binds on the localhost IPv4 address 127.0.0.1. The server can only be accessed from the local host, it cannot be accessed from other hosts on the network.

Example1 expression
acceptorLocal = Unfold.first (127,0,0,1) TCP.acceptorOnAddr

TCP clients

2 declarations

IP Address based operations.

Unfolds

Streams

withConnection addr port act opens a connection to the specified IPv4 host address and port and passes the resulting socket handle to the computation act. The handle will be closed on exit from withConnection, whether by normal termination or by raising an exception. If closing the handle raises an exception, then this exception will be raised by withConnection rather than any exception raised by act.

Pre-release

Source

Sink

Transformation

Deprecated

2 declarations