Safe Haskell | None |
---|---|
Language | Haskell2010 |
Communicate over a connection using immutable byte arrays.
Reception functions return ByteArray
instead of Bytes
since
this result always takes up the entirity of a ByteArray
. The
Bytes
would have redundant information since the offset would
be zero and the length would be the length of the ByteArray
payload.
Synopsis
- send :: Connection -> Bytes -> IO (Either (SendException Uninterruptible) ())
- receiveExactly :: Connection -> Int -> IO (Either (ReceiveException Uninterruptible) ByteArray)
- receiveOnce :: Connection -> Int -> IO (Either (ReceiveException Uninterruptible) ByteArray)
- receiveBetween :: Connection -> Int -> Int -> IO (Either (ReceiveException Uninterruptible) ByteArray)
Documentation
:: Connection | Connection |
-> Bytes | Slice of a buffer |
-> IO (Either (SendException Uninterruptible) ()) |
Send a slice of a buffer. If needed, this calls POSIX send
repeatedly
until the entire contents of the buffer slice have been sent.
:: Connection | Connection |
-> Int | Exact number of bytes to receive |
-> IO (Either (ReceiveException Uninterruptible) ByteArray) |
Receive a number of bytes exactly equal to the length of the
buffer slice. If needed, this may call recv
repeatedly until
the requested number of bytes have been received.
:: Connection | Connection |
-> Int | Maximum number of bytes to receive |
-> IO (Either (ReceiveException Uninterruptible) ByteArray) |
Receive at most the specified number of bytes. This
only makes multiple calls to POSIX recv
if EAGAIN is returned. It makes at
most one recv
call that successfully fills the buffer.
:: Connection | Connection |
-> Int | Minimum number of bytes to receive |
-> Int | Maximum number of bytes to receive |
-> IO (Either (ReceiveException Uninterruptible) ByteArray) |
Receive a number of bytes that is between the inclusive lower and
upper bounds. If needed, this may call recv
repeatedly until the
minimum requested number of bytes have been received.