Safe Haskell | None |
---|---|
Language | Haskell98 |
Simple tools for establishing and using Secure WebSockets connections on
top of TLS (i.e, wss://
).
See the
network-simple-ws
package for insecure WebSockets (i.e, ws://
) support.
Notice that, currently, this is package offers tools that are mostly intreresting from a client's point of view. Server side support will come later.
Synopsis
- data Connection
- send :: MonadIO m => Connection -> ByteString -> m ()
- recv :: MonadIO m => Connection -> m ByteString
- connect :: (MonadIO m, MonadMask m) => ClientSettings -> HostName -> ServiceName -> ByteString -> [(ByteString, ByteString)] -> ((Connection, SockAddr) -> m r) -> m r
- connectOverSOCKS5 :: (MonadIO m, MonadMask m) => HostName -> ServiceName -> ClientSettings -> HostName -> ServiceName -> ByteString -> [(ByteString, ByteString)] -> ((Connection, SockAddr, SockAddr) -> m r) -> m r
- streamFromContext :: MonadIO m => Context -> m Stream
Documentation
data Connection #
send :: MonadIO m => Connection -> ByteString -> m () #
Send bytes to the remote end.
Takes a lazy ByteString
.
recv :: MonadIO m => Connection -> m ByteString #
Receive bytes from the remote end.
Returns a strict ByteString
.
Returns an empty string when the remote end gracefully closes the connection.
Client side
:: (MonadIO m, MonadMask m) | |
=> ClientSettings | TLS settings. |
-> HostName | Secure WebSockets server host name (e.g., |
-> ServiceName | Secure WebSockets server port (e.g., |
-> ByteString | Secure WebSockets resource (e.g., Leading |
-> [(ByteString, ByteString)] | Extra HTTP Headers
(e.g., |
-> ((Connection, SockAddr) -> m r) | Computation to run after establishing a Secure WebSockets to the remote server. Takes the WebSockets connection and remote end address. |
-> m r |
Connect to the specified Secure WebSockets server.
:: (MonadIO m, MonadMask m) | |
=> HostName | SOCKS5 proxy server hostname or IP address. |
-> ServiceName | SOCKS5 proxy server service port name or number. |
-> ClientSettings | TLS settings. |
-> HostName | Destination Secure WebSockets server hostname or IP address. We connect to this host through the SOCKS5 proxy specified in the previous arguments. Note that if hostname resolution on this |
-> ServiceName | Destination Secure WebSockets server port (e.g., |
-> ByteString | WebSockets resource (e.g., Leading |
-> [(ByteString, ByteString)] | Extra HTTP Headers
(e.g., |
-> ((Connection, SockAddr, SockAddr) -> m r) | Computation taking a |
-> m r |
Like connect
, but connects to the destination server through a SOCKS5
proxy.
Low level
streamFromContext :: MonadIO m => Context -> m Stream Source #
Obtain a Stream
implemented using the given TLS Context
. You can
use the
network-simple-tls
library to get one of those.