network- Low-level networking interface

Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/network/LICENSE)
Safe HaskellNone




The Network.BSD module defines Haskell bindings to network programming functionality provided by BSD Unix derivatives.


Host names

type HostName = String #

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

getHostName :: IO HostName #

Calling getHostName returns the standard host name for the current processor, as set at boot time.

getHostByName :: HostName -> IO HostEntry #

Resolve a HostName to IPv4 address.

getHostByAddr :: Family -> HostAddress -> IO HostEntry #

Get a HostEntry corresponding to the given address and family. Note that only IPv4 is currently supported.

Low level functionality

Service names

Low level functionality

Protocol names

defaultProtocol :: ProtocolNumber #

This is the default protocol for a given service.

Low level functionality

Port numbers

data PortNumber #

Use the Num instance (i.e. use a literal) to create a PortNumber value with the correct network-byte-ordering. You should not use the PortNum constructor. It will be removed in the next release.

>>> 1 :: PortNumber
>>> read "1" :: PortNumber


Enum PortNumber # 
Eq PortNumber # 
Integral PortNumber # 
Num PortNumber # 
Ord PortNumber # 
Read PortNumber # 
Real PortNumber # 
Show PortNumber # 
Storable PortNumber # 

Network names

getNetworkEntries :: Bool -> IO [NetworkEntry] #

Get the list of network entries.

Low level functionality

setNetworkEntry :: Bool -> IO () #

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

endNetworkEntry :: IO () #

Close the connection to the network name database.

Interface names