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.
accept = TCP.acceptOnAddr (0,0,0,0)Pre-release
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulestreamly-0.10.1Haskell2010
Combinators to build Inet/TCP clients and servers.
To execute the code examples provided in this module in ghci, please run the following commands first.
:mimport qualified Streamly.Data.Unfold as Unfoldimport qualified Streamly.Network.Inet.TCP as TCP
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.
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.
acceptLocal = TCP.acceptOnAddr (127,0,0,1)Pre-release
Like accept but binds on the specified IPv4 address.
acceptOnAddr = TCP.acceptOnAddrWith []Pre-release
Like acceptOnAddr but with the ability to specify a list of socket options.
Pre-release
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.
acceptor = Unfold.first (0,0,0,0) TCP.acceptorOnAddrLike 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.
acceptorLocal = Unfold.first (127,0,0,1) TCP.acceptorOnAddrUnfold a tuple (ipAddr, port) into a stream of connected TCP sockets.
ipAddr is the local IP address and port is the local port on which
connections are accepted.
IP Address based operations.
Connect to the specified IP address and port number. Returns a connected socket or throws an exception.
Connect to a remote host using IP address and port and run the supplied action on the resulting socket. withConnectionM makes sure that the socket is closed on normal termination or in case of an exception. If closing the socket raises an exception, then this exception will be raised by withConnectionM.
Pre-release
Transform an Unfold from a Socket to an unfold from a remote IP address and port. The resulting unfold opens a socket, uses it using the supplied unfold and then makes sure that the socket is closed on normal termination or in case of an exception. If closing the socket raises an exception, then this exception will be raised by usingConnection.
Pre-release
reader :: (MonadCatch m, MonadAsync m) => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Word8Read a stream from the supplied IPv4 host address and port number.
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
Read a stream from the supplied IPv4 host address and port number.
Pre-release
Write a stream to the supplied IPv4 host address and port number.
Like write but provides control over the write buffer. Output will be written to the IO device as soon as we collect the specified number of input elements.
Write a stream to the supplied IPv4 host address and port number.
Pre-release
Like write but provides control over the write buffer. Output will be written to the IO device as soon as we collect the specified number of input elements.
Pre-release
Write a stream of arrays to the supplied IPv4 host address and port number.
Write a stream of arrays to the supplied IPv4 host address and port number.
Pre-release
Send an input stream to a remote host and produce the output stream from the host. The server host just acts as a transformation function on the input stream. Both sending and receiving happen asynchronously.
Pre-release
Deprecated. Use "acceptor" instead.
Deprecated. Use "acceptorLocal" instead.