HTTP-3001.0.1Source codeContentsIndex
Network.TCP
Portabilitynon-portable (not tested)
Stabilityexperimental
Maintainerbjorn@bringert.net
Contents
Connections
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 Simon Foster: - Split module up into to sepearate Network.[Stream,TCP,HTTP] modules
Synopsis
data Conn
= MkConn {
connSock :: !Socket
connAddr :: !SockAddr
connBffr :: !String
connHost :: String
}
| ConnClosed
newtype Connection = ConnRef {
getRef :: IORef Conn
}
openTCP :: String -> IO Connection
openTCPPort :: String -> Int -> IO Connection
isConnectedTo :: Connection -> String -> IO Bool
Connections
data Conn Source
The Conn object allows input buffering, and maintenance of some admin-type data.
Constructors
MkConn
connSock :: !Socket
connAddr :: !SockAddr
connBffr :: !String
connHost :: String
ConnClosed
show/hide Instances
newtype Connection Source
The Connection newtype is a wrapper that allows us to make connections an instance of the StreamIn/Out classes, 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.
Constructors
ConnRef
getRef :: IORef Conn
show/hide Instances
openTCP :: String -> IO ConnectionSource
Open a connection to port 80 on a remote host.
openTCPPort :: String -> Int -> IO ConnectionSource

This function establishes a connection to a remote host, it uses getHostByName which interrogates the DNS system, hence may trigger a network connection.

Add a persistant option? Current persistant is default. Use Result type for synchronous exception reporting?

isConnectedTo :: Connection -> String -> IO BoolSource
Checks both that the underlying Socket is connected and that the connection peer matches the given host name (which is recorded locally).
Produced by Haddock version 2.6.0