HTTP-4000.0.4: A library for client-side HTTPContentsIndex
Network.TCP
Portabilitynon-portable (not tested)
Stabilityexperimental
Maintainerbjorn@bringert.net
Description

An easy access TCP library. Makes the use of TCP in Haskell much easier. This was originally part of Gray's\/Bringert's HTTP module.

  • Changes by Robin Bate Boerop robin@bateboerop.name: - Made dependencies explicit in import statements. - Removed false dependencies from import statements. - Removed unused exported functions.
  • Changes by Simon Foster: - Split module up into to separate Network.[Stream,TCP,HTTP] modules
Synopsis
data Connection
openTCPPort :: String -> Int -> IO Connection
isConnectedTo :: Connection -> String -> IO Bool
openTCPConnection :: BufferType ty => String -> Int -> IO (HandleStream ty)
isTCPConnectedTo :: HandleStream ty -> String -> IO Bool
data HandleStream a
class BufferType bufType => HStream bufType where
openStream :: String -> Int -> IO (HandleStream bufType)
readLine :: HandleStream bufType -> IO (Result bufType)
readBlock :: HandleStream bufType -> Int -> IO (Result bufType)
writeBlock :: HandleStream bufType -> bufType -> IO (Result ())
close :: HandleStream bufType -> IO ()
data StreamHooks ty = StreamHooks {
hook_readLine :: (ty -> String) -> Result ty -> IO ()
hook_readBlock :: (ty -> String) -> Int -> Result ty -> IO ()
hook_writeBlock :: (ty -> String) -> ty -> Result () -> IO ()
hook_close :: IO ()
}
nullHooks :: StreamHooks ty
setStreamHooks :: HandleStream ty -> StreamHooks ty -> IO ()
Documentation
data Connection
The Connection newtype is a wrapper that allows us to make connections an instance of the Stream class, without ghc extensions. While this looks sort of like a generic reference to the transport layer it is actually TCP specific, which can be seen in the implementation of the 'Stream Connection' instance.
show/hide Instances
openTCPPort :: String -> Int -> IO Connection
This function establishes a connection to a remote host, it uses getHostByName which interrogates the DNS system, hence may trigger a network connection.
isConnectedTo :: Connection -> String -> IO Bool
Checks both that the underlying Socket is connected and that the connection peer matches the given host name (which is recorded locally).
openTCPConnection :: BufferType ty => String -> Int -> IO (HandleStream ty)
isTCPConnectedTo :: HandleStream ty -> String -> IO Bool
data HandleStream a
class BufferType bufType => HStream bufType where
Methods
openStream :: String -> Int -> IO (HandleStream bufType)
readLine :: HandleStream bufType -> IO (Result bufType)
readBlock :: HandleStream bufType -> Int -> IO (Result bufType)
writeBlock :: HandleStream bufType -> bufType -> IO (Result ())
close :: HandleStream bufType -> IO ()
show/hide Instances
data StreamHooks ty
Constructors
StreamHooks
hook_readLine :: (ty -> String) -> Result ty -> IO ()
hook_readBlock :: (ty -> String) -> Int -> Result ty -> IO ()
hook_writeBlock :: (ty -> String) -> ty -> Result () -> IO ()
hook_close :: IO ()
show/hide Instances
Eq ty => Eq (StreamHooks ty)
nullHooks :: StreamHooks ty
setStreamHooks :: HandleStream ty -> StreamHooks ty -> IO ()
Produced by Haddock version 2.3.0