tcp-streams-0.6.0.0: One stop solution for tcp client and server with tls support.

Safe HaskellNone
LanguageHaskell2010

System.IO.Streams.TLS

Contents

Description

This module provides convenience functions for interfacing io-streams with tls. the default receive buffer size is decided by tls. sending is unbuffered, anything write into OutputStream will be immediately send to underlying socket.

The same exceptions rule which applied to TCP apply here, with addtional TLSException to be watched out.

This module is intended to be imported qualified, e.g.:

import qualified System.IO.Streams.TLS as TLS

Synopsis

client

connect Source

Arguments

:: ClientParams

check Data.TLSSetting.

-> Maybe String

Optional certificate subject name, if set to Nothing then we will try to verify HostName as subject name.

-> HostName

hostname to connect to

-> PortNumber

port number to connect to

-> IO (InputStream ByteString, OutputStream ByteString, Context) 

Convenience function for initiating an TLS connection to the given (HostName, PortNumber) combination.

Note that sending an end-of-file to the returned OutputStream will not close the underlying TLS connection; to do that, call close

this operation will throw TLSException on failure.

withConnection Source

Arguments

:: ClientParams 
-> Maybe HostName 
-> HostName 
-> PortNumber 
-> (InputStream ByteString -> OutputStream ByteString -> Context -> IO a)

Action to run with the new connection

-> IO a 

Convenience function for initiating an TLS connection to the given (HostName, PortNumber) combination. The socket and TLS connection are closed and deleted after the user handler runs.

server

accept Source

Arguments

:: ServerParams

check Data.TLSSetting.

-> Socket

the listening Socket.

-> IO (InputStream ByteString, OutputStream ByteString, Context, SockAddr) 

Accept a new connection from remote client, return a InputStream / OutputStream pair and remote SockAddr, you should call bindAndListen first.

this operation will throw TLSException on failure.

helpers

tlsToStreams Source

Arguments

:: Context

TLS connection object

-> IO (InputStream ByteString, OutputStream ByteString) 

Given an existing TLS Context connection, produces an InputStream / OutputStream pair.

close :: Context -> IO () Source

Close a TLS Context and its underlying socket.

re-export helpers