Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
You should handle IOError
when you read/write these streams for safety.
- connect :: ClientParams -> Maybe String -> HostName -> PortNumber -> IO (InputStream ByteString, OutputStream ByteString, Context)
- withConnection :: ClientParams -> Maybe HostName -> HostName -> PortNumber -> (InputStream ByteString -> OutputStream ByteString -> Context -> IO a) -> IO a
- accept :: ServerParams -> Socket -> IO (InputStream ByteString, OutputStream ByteString, Context, SockAddr)
- tlsToStreams :: Context -> IO (InputStream ByteString, OutputStream ByteString)
- closeTLS :: Context -> IO ()
client
:: ClientParams | check Data.TLSSetting. |
-> Maybe String | Optional certificate subject name, if set to |
-> 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
(
combination.HostName
, PortNumber
)
Note that sending an end-of-file to the returned OutputStream
will not
close the underlying TLS connection; to do that, call closeTLS
this operation will throw TLSException
on failure.
:: 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
(
combination. The socket and TLS connection are
closed and deleted after the user handler runs.HostName
, PortNumber
)
server
:: ServerParams | check Data.TLSSetting. |
-> Socket | the listening |
-> 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
:: Context | TLS connection object |
-> IO (InputStream ByteString, OutputStream ByteString) |
Given an existing TLS Context
connection, produces an InputStream
/
OutputStream
pair.