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

Modulenetwork-bsd-2.8.1.0Haskell2010

Network.BSD

The Network.BSD module defines Haskell bindings to network programming functionality (mostly network database operations) provided by BSD Unix derivatives.

NOTE: Some of the types are reexported from Network.Socket in order to make the network-bsd API self-contained.

Windows compatibility

The following functions are not exported by Network.BSD on the Windows platform:

  • 13 types
  • 30 values

Host names and network addresses

75 declarations
typetype HostName = String
#

Either a host name e.g., "haskell.org" or a numeric host address string consisting of a dotted decimal IPv4 address or an IPv6 address e.g., "192.168.0.1".

typetype HostAddress = Word32
#

The raw network byte order number is read using host byte order. Therefore on little-endian architectures the byte order is swapped. For example 127.0.0.1 is represented as 0x0100007f on little-endian hosts and as 0x7f000001 on big-endian hosts.

For direct manipulation prefer hostAddressToTuple and tupleToHostAddress.

newtypenewtype Family
#

Address families. The AF_xxxxx constants are widely used as synonyms for the corresponding PF_xxxxx protocol family values, to which they are numerically equal in mainstream socket API implementations.

Strictly correct usage would be to pass the PF_xxxxx constants as the first argument when creating a Socket, while the AF_xxxxx constants should be used as addrFamily values with getAddrInfo. For now only the AF_xxxxx constants are provided.

Some of the defined patterns may be unsupported on some systems: see isSupportedFamily.

Instances4Eq, Ord, Read, Show
  • Eq FamilyDefined in network-3.2.8.0 · Network.Socket.Types
  • Ord FamilyDefined in network-3.2.8.0 · Network.Socket.Types
  • Read FamilyDefined in network-3.2.8.0 · Network.Socket.Types
  • Show FamilyDefined in network-3.2.8.0 · Network.Socket.Types
patternpattern AF_ROUTE :: Family
#

Internal Routing Protocol (aka AF_NETLINK)

patternpattern AF_OSI :: Family
#

umbrella of all families used by OSI

patternpattern AF_COIP :: Family
#

connection-oriented IP, aka ST II

patternpattern AF_ISDN :: Family
#

Integrated Services Digital Network

datadata HostEntry
#

Representation of the POSIX hostent structure defined in netdb.h.

Constructors

Instances4Read, Show, Storable, NFData

Low level functionality

Service names

7 declarations
datadata ServiceEntry
#

Representation of the POSIX servent structure defined in netdb.h.

Constructors

Instances3Show, Storable, NFData
typetype ServiceName = String
#

Either a service name e.g., "http" or a numeric port number.

newtypenewtype PortNumber
#

Port number. Use the Num instance (i.e. use a literal) to create a PortNumber value.

Example6 expressions
1 :: PortNumber1read "1" :: PortNumber1show (12345 :: PortNumber)"12345"50000 < (51000 :: PortNumber)True50000 < (52000 :: PortNumber)True50000 + (10000 :: PortNumber)60000
Instances10Bounded, Enum, Eq, Integral, Num, Ord, …

Low level functionality

Protocol names

8 declarations
datadata ProtocolEntry
#

Representation of the POSIX protoent structure defined in netdb.h.

Constructors

Instances4Read, Show, Storable, NFData

Low level functionality

Network names

6 declarations
datadata NetworkEntry
#

Representation of the POSIX netent structure defined in netdb.h.

Constructors

Instances4Read, Show, Storable, NFData

Low level functionality

valuesetNetworkEntry :: Bool -> IO ()
#

Open the network name database. The parameter specifies whether a connection is maintained open between various networkEntry calls

setnetent(3).

valueendNetworkEntry :: IO ()
#

Close the connection to the network name database.

endnetent(3).

Interface names

1 declaration