Copyright | (c) Eric Mertens, 2016 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module provides a uniform interface to network connections with optional support for TLS and SOCKS.
- data ConnectionParams = ConnectionParams {
- cpHost :: HostName
- cpPort :: PortNumber
- cpSocks :: Maybe SocksParams
- cpTls :: Maybe TlsParams
- data SocksParams = SocksParams {
- spHost :: HostName
- spPort :: PortNumber
- data TlsParams = TlsParams {}
- data Connection
- connect :: ConnectionParams -> IO Connection
- recvLine :: Connection -> Int -> IO (Maybe ByteString)
- send :: Connection -> ByteString -> IO ()
- close :: Connection -> IO ()
- data ConnectionFailure
Configuration
data ConnectionParams Source #
Parameters for connect
.
ConnectionParams | |
|
data SocksParams Source #
SOCKS5 connection parameters
SocksParams | |
|
TLS connection parameters
Connections
data Connection Source #
A connection to a network service along with its read buffer used for line-oriented protocols. The connection could be a plain network connection, SOCKS connected, or TLS.
connect :: ConnectionParams -> IO Connection Source #
Open network connection to TCP service specified by the given parameters.
Throws IOError
, SocksError
, ProtocolError
, ConnectionFailure
recvLine :: Connection -> Int -> IO (Maybe ByteString) Source #
Receive a line from the network connection. Both
"rn"
and "n"
are recognized.
Throws: ConnectionAbruptlyTerminated
, ConnectionFailure
, IOError
send :: Connection -> ByteString -> IO () Source #
Send bytes on the network connection. Ensures that the whole message is sent.
Throws: IOError
, ProtocolError
close :: Connection -> IO () Source #
Close network connection.
Errors
data ConnectionFailure Source #
Type for errors that can be thrown by this package.
HostnameResolutionFailure IOError | Failure during |
ConnectionFailure [IOError] | Failure during |
LineTooLong | Failure during |
LineTruncated | Incomplete line during |