Copyright | (c) Lars Petersen 2015 |
---|---|
License | MIT |
Maintainer | info@lars-petersen.net |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
- data Stream
- sendAll :: Socket f Stream p -> ByteString -> MessageFlags -> IO Int
- sendAllLazy :: Socket f Stream p -> ByteString -> MessageFlags -> IO Int64
- sendAllBuilder :: Socket f Stream p -> Int -> Builder -> MessageFlags -> IO Int64
- receiveAll :: Socket f Stream p -> Int64 -> MessageFlags -> IO ByteString
Stream
Specialized send operations
sendAll
sendAll :: Socket f Stream p -> ByteString -> MessageFlags -> IO Int Source #
Sends a whole ByteString
with as many system calls as necessary
and returns the bytes sent (in this case just the ByteString
s
length
).
sendAllLazy
sendAllLazy :: Socket f Stream p -> ByteString -> MessageFlags -> IO Int64 Source #
Like sendAll
, but operates on lazy ByteString
s.
It uses sendAll
internally to send all chunks sequentially. The lock on
the socket is acquired for each chunk separately, so the socket can be read
from in an interleaving fashion.
sendAllBuilder
sendAllBuilder :: Socket f Stream p -> Int -> Builder -> MessageFlags -> IO Int64 Source #
Sends a whole Builder
without allocating ByteString
s.
If performance is an issue, this operation should be preferred over all
other solutions for sending stream data.
The operation alloca
tes a single buffer of the given size on entry and
reuses this buffer until the whole Builder
has been sent.
The count of all bytes sent is returned as there is no other efficient
way to determine a Builder
s size without actually building it.
Specialized receive operations
receiveAll
receiveAll :: Socket f Stream p -> Int64 -> MessageFlags -> IO ByteString Source #
Like receive
, but operates on lazy ByteString
s and
continues until either an empty part has been received (peer closed
the connection) or given buffer limit has been exceeded or an
exception occured.
- The
Int64
parameter is a soft limit on how many bytes to receive. Collection is stopped if the limit has been exceeded. The result might be up to one internal buffer size longer than the given limit. If the returnedByteString
s length is lower or eqal than the limit, the data has not been truncated and the transmission is complete.