network-2.6.3.1: Low-level networking interface

Copyright | (c) The University of Glasgow 2001
License | BSD-style (see the file libraries/network/LICENSE)
Maintainer | libraries@haskell.org
Stability | experimental
Portability | non-portable
Safe Haskell | None
Language | Haskell98

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
- Interface names

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 ()
- ifNameToIndex :: String -> IO (Maybe Int)

# 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 # |
Methods readsPrec :: Int -> ReadS HostEntry # readList :: ReadS [HostEntry] # readPrec :: ReadPrec HostEntry # readListPrec :: ReadPrec [HostEntry] #
Show HostEntry # |
Methods showsPrec :: Int -> HostEntry -> ShowS # show :: HostEntry -> String # showList :: [HostEntry] -> ShowS #
Storable HostEntry # |
Methods sizeOf :: HostEntry -> Int # alignment :: HostEntry -> Int # peekElemOff :: Ptr HostEntry -> Int -> IO HostEntry # pokeElemOff :: Ptr HostEntry -> Int -> HostEntry -> IO () # peekByteOff :: Ptr b -> Int -> IO HostEntry # pokeByteOff :: Ptr b -> Int -> HostEntry -> IO () # peek :: Ptr HostEntry -> IO HostEntry # poke :: Ptr HostEntry -> HostEntry -> IO () #

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 # |
Methods showsPrec :: Int -> ServiceEntry -> ShowS # show :: ServiceEntry -> String # showList :: [ServiceEntry] -> ShowS #
Storable ServiceEntry # |
Methods sizeOf :: ServiceEntry -> Int # alignment :: ServiceEntry -> Int # peekElemOff :: Ptr ServiceEntry -> Int -> IO ServiceEntry # pokeElemOff :: Ptr ServiceEntry -> Int -> ServiceEntry -> IO () # peekByteOff :: Ptr b -> Int -> IO ServiceEntry # pokeByteOff :: Ptr b -> Int -> ServiceEntry -> IO () # peek :: Ptr ServiceEntry -> IO ServiceEntry # poke :: Ptr ServiceEntry -> ServiceEntry -> IO () #

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 # |
Methods readsPrec :: Int -> ReadS ProtocolEntry # readList :: ReadS [ProtocolEntry] # readPrec :: ReadPrec ProtocolEntry # readListPrec :: ReadPrec [ProtocolEntry] #
Show ProtocolEntry # |
Methods showsPrec :: Int -> ProtocolEntry -> ShowS # show :: ProtocolEntry -> String # showList :: [ProtocolEntry] -> ShowS #
Storable ProtocolEntry # |
Methods sizeOf :: ProtocolEntry -> Int # alignment :: ProtocolEntry -> Int # peekElemOff :: Ptr ProtocolEntry -> Int -> IO ProtocolEntry # pokeElemOff :: Ptr ProtocolEntry -> Int -> ProtocolEntry -> IO () # peekByteOff :: Ptr b -> Int -> IO ProtocolEntry # pokeByteOff :: Ptr b -> Int -> ProtocolEntry -> IO () # peek :: Ptr ProtocolEntry -> IO ProtocolEntry # poke :: Ptr ProtocolEntry -> ProtocolEntry -> IO () #

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 #

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
    1
    >>> read "1" :: PortNumber
    1

Instances

Enum PortNumber # |
Methods succ :: PortNumber -> PortNumber # pred :: PortNumber -> PortNumber # toEnum :: Int -> PortNumber # fromEnum :: PortNumber -> Int # enumFrom :: PortNumber -> [PortNumber] # enumFromThen :: PortNumber -> PortNumber -> [PortNumber] # enumFromTo :: PortNumber -> PortNumber -> [PortNumber] # enumFromThenTo :: PortNumber -> PortNumber -> PortNumber -> [PortNumber] #
Eq PortNumber # |
Methods (==) :: PortNumber -> PortNumber -> Bool # (/=) :: PortNumber -> PortNumber -> Bool #
Integral PortNumber # |
Methods quot :: PortNumber -> PortNumber -> PortNumber # rem :: PortNumber -> PortNumber -> PortNumber # div :: PortNumber -> PortNumber -> PortNumber # mod :: PortNumber -> PortNumber -> PortNumber # quotRem :: PortNumber -> PortNumber -> (PortNumber, PortNumber) # divMod :: PortNumber -> PortNumber -> (PortNumber, PortNumber) # toInteger :: PortNumber -> Integer #
Num PortNumber # |
Methods (+) :: PortNumber -> PortNumber -> PortNumber # (-) :: PortNumber -> PortNumber -> PortNumber # (*) :: PortNumber -> PortNumber -> PortNumber # negate :: PortNumber -> PortNumber # abs :: PortNumber -> PortNumber # signum :: PortNumber -> PortNumber # fromInteger :: Integer -> PortNumber #
Ord PortNumber # |
Methods compare :: PortNumber -> PortNumber -> Ordering # (<) :: PortNumber -> PortNumber -> Bool # (<=) :: PortNumber -> PortNumber -> Bool # (>) :: PortNumber -> PortNumber -> Bool # (>=) :: PortNumber -> PortNumber -> Bool # max :: PortNumber -> PortNumber -> PortNumber # min :: PortNumber -> PortNumber -> PortNumber #
Read PortNumber # |
Methods readsPrec :: Int -> ReadS PortNumber # readList :: ReadS [PortNumber] # readPrec :: ReadPrec PortNumber # readListPrec :: ReadPrec [PortNumber] #
Real PortNumber # |
Methods toRational :: PortNumber -> Rational #
Show PortNumber # |
Methods showsPrec :: Int -> PortNumber -> ShowS # show :: PortNumber -> String # showList :: [PortNumber] -> ShowS #
Storable PortNumber # |
Methods sizeOf :: PortNumber -> Int # alignment :: PortNumber -> Int # peekElemOff :: Ptr PortNumber -> Int -> IO PortNumber # pokeElemOff :: Ptr PortNumber -> Int -> PortNumber -> IO () # peekByteOff :: Ptr b -> Int -> IO PortNumber # pokeByteOff :: Ptr b -> Int -> PortNumber -> IO () # peek :: Ptr PortNumber -> IO PortNumber # poke :: Ptr PortNumber -> PortNumber -> IO () #

# Network names

type NetworkName = String #

type NetworkAddr = CULong #

data NetworkEntry #

Constructors

NetworkEntry |
Fields networkName :: NetworkName networkAliases :: [NetworkName] networkFamily :: Family networkAddress :: NetworkAddr

Instances

Read NetworkEntry # |
Methods readsPrec :: Int -> ReadS NetworkEntry # readList :: ReadS [NetworkEntry] # readPrec :: ReadPrec NetworkEntry # readListPrec :: ReadPrec [NetworkEntry] #
Show NetworkEntry # |
Methods showsPrec :: Int -> NetworkEntry -> ShowS # show :: NetworkEntry -> String # showList :: [NetworkEntry] -> ShowS #
Storable NetworkEntry # |
Methods sizeOf :: NetworkEntry -> Int # alignment :: NetworkEntry -> Int # peekElemOff :: Ptr NetworkEntry -> Int -> IO NetworkEntry # pokeElemOff :: Ptr NetworkEntry -> Int -> NetworkEntry -> IO () # peekByteOff :: Ptr b -> Int -> IO NetworkEntry # pokeByteOff :: Ptr b -> Int -> NetworkEntry -> IO () # peek :: Ptr NetworkEntry -> IO NetworkEntry # poke :: Ptr NetworkEntry -> NetworkEntry -> IO () #

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.

# Interface names

ifNameToIndex :: String -> IO (Maybe Int) #