HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulestreaming-commons-0.2.3.0Haskell2010

Data.Streaming.Network

  • 9 types
  • 5 classes
  • 51 values

Types

8 declarations
datadata HostPreference
#

Which host to bind.

Note: The IsString instance recognizes the following special values:

  • * means HostAny - "any IPv4 or IPv6 hostname"

  • *4 means HostIPv4 - "any IPv4 or IPv6 hostname, IPv4 preferred"

  • !4 means HostIPv4Only - "any IPv4 hostname"

  • *6 means HostIPv6@ - "any IPv4 or IPv6 hostname, IPv6 preferred"

  • !6 means HostIPv6Only - "any IPv6 hostname"

Note that the permissive * values allow binding to an IPv4 or an IPv6 hostname, which means you might be able to successfully bind to a port more times than you expect (eg once on the IPv4 localhost 127.0.0.1 and again on the IPv6 localhost 0:0:0:0:0:0:0:1).

Any other value is treated as a hostname. As an example, to bind to the IPv4 local host only, use "127.0.0.1".

Instances5Eq, Ord, Read, Show, IsString
datadata AppData
#

The data passed to an Application.

Instances1HasReadWrite
datadata AppDataUnix
#

The data passed to a Unix domain sockets Application.

Instances1HasReadWrite

Smart constructors

Classes

classclass HasReadBufferSize a where
#

Since 0.1.13

Methods

Instances4HasReadBufferSize

Setters

Getters

valueappCloseConnection :: AppData -> IO ()
#

Close the underlying connection. One possible use case is simulating connection failures in a test suite.

Since 0.1.6

Functions

0 declarations

General

valueacceptSafe :: Socket -> IO (Socket, SockAddr)
#

Try to accept a connection, recovering automatically from exceptions.

As reported by Kazu against Warp, "resource exhausted (Too many open files)" may be thrown by accept(). This function will catch that exception, wait a second, and then try again.

Get a port from the IANA list of unassigned ports.

Internally, this function uses an IORef to cycle through the list of ports

TCP

Attempt to bind a listening Socket on the given host/port. If no host is given, will use the first address available. maxListenQueue is topically 128 which is too short for high performance servers. So, we specify 'max 2048 maxListenQueue' to the listen queue.

valuerunTCPServer :: ServerSettings -> (AppData -> IO ()) -> IO a
#

Run an Application with the given settings. This function will create a new listening socket, accept connections on it, and spawn a new thread for each connection.

UDP

Unix

valuerunUnixServer :: ServerSettingsUnix -> (AppDataUnix -> IO ()) -> IO a
#

Run an Application with the given settings. This function will create a new listening socket, accept connections on it, and spawn a new thread for each connection.