HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

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:

Contents
  1. Host names and network addresses
  2. Low level functionality
  3. Service names
  4. Low level functionality
  5. Protocol names
  6. Low level functionality
  7. Network names
  8. Low level functionality
  9. Interface names
Synopsis

Host names and network addresses

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.9.0 · Network.Socket.Types
  • Ord FamilyDefined in network-3.2.9.0 · Network.Socket.Types
  • Read FamilyDefined in network-3.2.9.0 · Network.Socket.Types
  • Show FamilyDefined in network-3.2.9.0 · Network.Socket.Types
datadata HostEntry

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

Constructors

Instances4Read, Show, Storable, NFData

Low level functionality

Service names

datadata ServiceEntry

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

Constructors

Instances3Show, Storable, NFData
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

datadata ProtocolEntry

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

Constructors

Instances4Read, Show, Storable, NFData

Low level functionality

Network names

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).

Interface names