network-2.4.1.2: Low-level networking interface

Portability | non-portable
Stability | experimental
Maintainer | libraries@haskell.org
Safe Haskell | None

Network.BSD

Contents

- Host names
  - Low level functionality
- Service names
  - Low level functionality
- Protocol names
  - Low level functionality
- Port numbers
- Network names
  - Low level functionality

Description

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

Synopsis

- type HostName = String
- getHostName :: IO HostName
- data HostEntry = HostEntry {
  - hostName :: HostName
  - hostAliases :: [HostName]
  - hostFamily :: Family
  - hostAddresses :: [HostAddress]
  }
- getHostByName :: HostName -> IO HostEntry
- getHostByAddr :: Family -> HostAddress -> IO HostEntry
- hostAddress :: HostEntry -> HostAddress
- getHostEntries :: Bool -> IO [HostEntry]
- setHostEntry :: Bool -> IO ()
- getHostEntry :: IO HostEntry
- endHostEntry :: IO ()
- data ServiceEntry = ServiceEntry {
  - serviceName :: ServiceName
  - serviceAliases :: [ServiceName]
  - servicePort :: PortNumber
  - serviceProtocol :: ProtocolName
  }
- type ServiceName = String
- getServiceByName :: ServiceName -> ProtocolName -> IO ServiceEntry
- getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry
- getServicePortNumber :: ServiceName -> IO PortNumber
- getServiceEntries :: Bool -> IO [ServiceEntry]
- getServiceEntry :: IO ServiceEntry
- setServiceEntry :: Bool -> IO ()
- endServiceEntry :: IO ()
- type ProtocolName = String
- type ProtocolNumber = CInt
- data ProtocolEntry = ProtocolEntry {
  - protoName :: ProtocolName
  - protoAliases :: [ProtocolName]
  - protoNumber :: ProtocolNumber
  }
- getProtocolByName :: ProtocolName -> IO ProtocolEntry
- getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry
- getProtocolNumber :: ProtocolName -> IO ProtocolNumber
- defaultProtocol :: ProtocolNumber
- getProtocolEntries :: Bool -> IO [ProtocolEntry]
- setProtocolEntry :: Bool -> IO ()
- getProtocolEntry :: IO ProtocolEntry
- endProtocolEntry :: IO ()
- data PortNumber
- type NetworkName = String
- type NetworkAddr = CULong
- data NetworkEntry = NetworkEntry {
  - networkName :: NetworkName
  - networkAliases :: [NetworkName]
  - networkFamily :: Family
  - networkAddress :: NetworkAddr
  }
- getNetworkByName :: NetworkName -> IO NetworkEntry
- getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry
- getNetworkEntries :: Bool -> IO [NetworkEntry]
- setNetworkEntry :: Bool -> IO ()
- getNetworkEntry :: IO NetworkEntry
- endNetworkEntry :: IO ()

# Host names

type 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"`.

getHostName :: IO HostName

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

data HostEntry

Constructors

HostEntry |

Fields

hostName :: HostName
hostAliases :: [HostName]
hostFamily :: Family
hostAddresses :: [HostAddress]

Instances

Read HostEntry |
Show HostEntry |
Typeable HostEntry |
Storable HostEntry |

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.

hostAddress :: HostEntry -> HostAddress

getHostEntries :: Bool -> IO [HostEntry]

## Low level functionality

setHostEntry :: Bool -> IO ()

getHostEntry :: IO HostEntry

endHostEntry :: IO ()

# Service names

data ServiceEntry

Constructors

ServiceEntry |

Fields

serviceName :: ServiceName
serviceAliases :: [ServiceName]
servicePort :: PortNumber
serviceProtocol :: ProtocolName

Instances

Show ServiceEntry |
Typeable ServiceEntry |
Storable ServiceEntry |

type ServiceName = String

getServiceByName :: ServiceName -> ProtocolName -> IO ServiceEntry

Get service by name.

getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry

Get the service given a `PortNumber` and `ProtocolName`.

getServicePortNumber :: ServiceName -> IO PortNumber

Get the `PortNumber` corresponding to the `ServiceName`.

getServiceEntries :: Bool -> IO [ServiceEntry]

## Low level functionality

getServiceEntry :: IO ServiceEntry

setServiceEntry :: Bool -> IO ()

endServiceEntry :: IO ()

# Protocol names

type ProtocolName = String

type ProtocolNumber = CInt

data ProtocolEntry

Constructors

ProtocolEntry |

Fields

protoName :: ProtocolName
protoAliases :: [ProtocolName]
protoNumber :: ProtocolNumber

Instances

Read ProtocolEntry |
Show ProtocolEntry |
Typeable ProtocolEntry |
Storable ProtocolEntry |

getProtocolByName :: ProtocolName -> IO ProtocolEntry

getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry

getProtocolNumber :: ProtocolName -> IO ProtocolNumber

defaultProtocol :: ProtocolNumber

This is the default protocol for a given service.

getProtocolEntries :: Bool -> IO [ProtocolEntry]

## Low level functionality

setProtocolEntry :: Bool -> IO ()

getProtocolEntry :: IO ProtocolEntry

endProtocolEntry :: IO ()

# Port numbers

data PortNumber

Instances

Enum PortNumber |
Eq PortNumber |
Integral PortNumber |
Num PortNumber |
Ord PortNumber |
Real PortNumber |
Show PortNumber |
Typeable PortNumber |
Storable PortNumber |

# Network names

type NetworkName = String

type NetworkAddr = CULong

data NetworkEntry

Constructors

NetworkEntry |

Fields

networkName :: NetworkName
networkAliases :: [NetworkName]
networkFamily :: Family
networkAddress :: NetworkAddr

Instances

Read NetworkEntry |
Show NetworkEntry |
Typeable NetworkEntry |
Storable NetworkEntry |

getNetworkByName :: NetworkName -> IO NetworkEntry

getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry

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

getNetworkEntry :: IO NetworkEntry

endNetworkEntry :: IO ()

Close the connection to the network name database.