uniform-io-0.2.0.0: Uniform IO over files, network, watever.

Safe HaskellNone
LanguageHaskell2010

System.IO.Uniform

Description

Uniform-IO provides a typeclass for uniform access of different types of targets, and implementations for abstracting standard streams, files and network connections. This module also provides TLS wraping over other IO targets.

Synopsis

Documentation

class UniformIO a where Source

Typeclass for uniform IO targets.

Methods

uRead :: a -> Int -> IO ByteString Source

uRead fd n

Reads a block of at most n bytes of data from the IO target. Reading will block if there's no data available, but will return immediately if any amount of data is availble.

uPut :: a -> ByteString -> IO () Source

uPut fd text

Writes all the bytes of text into the IO target. Takes care of retrying if needed.

uClose :: a -> IO () Source

fClose fd

Closes the IO target, releasing any allocated resource. Resources may leak if not called for every oppened fd.

startTls :: TlsSettings -> a -> IO TlsStream Source

startTLS fd

Starts a TLS connection over the IO target.

isSecure :: a -> Bool Source

isSecure fd

Indicates whether the data written or read from fd is secure at transport.

Instances

UniformIO StdIO

UniformIO IP connections.

UniformIO TlsStream

UniformIO wrapper that applies TLS to communication on IO target. This type is constructed by calling startTls on other targets.

UniformIO FileIO

UniformIO type for file IO.

UniformIO SocketIO

UniformIO IP connections.

UniformIO SomeIO 

data SocketIO Source

Instances

UniformIO SocketIO

UniformIO IP connections.

data FileIO Source

Instances

UniformIO FileIO

UniformIO type for file IO.

data StdIO Source

Instances

UniformIO StdIO

UniformIO IP connections.

data TlsStream Source

Instances

UniformIO TlsStream

UniformIO wrapper that applies TLS to communication on IO target. This type is constructed by calling startTls on other targets.

data BoundedPort Source

A bounded IP port from where to accept SocketIO connections.

data SomeIO Source

A type that wraps any type in the UniformIO class.

Constructors

forall a . UniformIO a => SomeIO a 

Instances

connectTo :: IP -> Int -> IO SocketIO Source

ConnecctTo ipAddress port

Connects to the given port of the host at the given IP address.

connectToHost :: String -> Int -> IO SocketIO Source

connectToHost hostName port

Connects to the given host and port.

bindPort :: Int -> IO BoundedPort Source

bindPort port Binds to the given IP port, becoming ready to accept connections on it. Binding to port numbers under 1024 will fail unless performed by the superuser, once bounded, a process can reduce its privileges and still accept clients on that port.

accept :: BoundedPort -> IO SocketIO Source

accept port

Accept clients on a port previously bound with bindPort.

openFile :: String -> IO FileIO Source

Open a file for bidirectional IO.

getPeer :: SocketIO -> IO (IP, Int) Source

Gets the address of the peer socket of a internet connection.

closePort :: BoundedPort -> IO () Source

Closes a BoundedPort, and releases any resource used by it.