Safe Haskell | None |
---|---|
Language | Haskell98 |
This minimal module exports facilities that ease the usage of TCP
- fromSocket :: MonadIO m => Socket -> Int -> Producer' ByteString m ()
- fromSocketTimeout :: MonadIO m => Int -> Socket -> Int -> Producer' ByteString m ()
- fromSocketN :: MonadIO m => Socket -> Int -> Server' Int ByteString m ()
- fromSocketTimeoutN :: MonadIO m => Int -> Socket -> Int -> Server' Int ByteString m ()
- toSocket :: MonadIO m => Socket -> Consumer' ByteString m r
- toSocketLazy :: MonadIO m => Socket -> Consumer' ByteString m r
- toSocketMany :: MonadIO m => Socket -> Consumer' [ByteString] m r
- toSocketTimeout :: MonadIO m => Int -> Socket -> Consumer' ByteString m r
- toSocketTimeoutLazy :: MonadIO m => Int -> Socket -> Consumer' ByteString m r
- toSocketTimeoutMany :: MonadIO m => Int -> Socket -> Consumer' [ByteString] m r
- module Network.Simple.TCP
Receiving
The following producers allow you to receive bytes from the remote end.
Besides the producers below, you might want to use Network.Simple.TCP's
recv
, which happens to be an Effect'
:
recv
::MonadIO
m =>Socket
->Int
->Effect'
m (Maybe
ByteString
)
:: MonadIO m | |
=> Socket | Connected socket. |
-> Int | Maximum number of bytes to receive and send
dowstream at once. Any positive value is fine, the
optimal value depends on how you deal with the
received data. Try using |
-> Producer' ByteString m () |
Receives bytes from the remote end and sends them downstream.
The number of bytes received at once is always in the interval [1 .. specified maximum].
This Producer'
returns if the remote peer closes its side of the connection
or EOF is received.
fromSocketTimeout :: MonadIO m => Int -> Socket -> Int -> Producer' ByteString m () Source #
Like fromSocket
, except with the first Int
argument you can specify
the maximum time that each interaction with the remote end can take. If such
time elapses before the interaction finishes, then an IOError
exception is
thrown. The time is specified in microseconds (1 second = 1e6 microseconds).
Bidirectional pipes
The following pipes are bidirectional, which means useful data can flow through them upstream and downstream. If you don't care about bidirectional pipes, just skip this section.
fromSocketN :: MonadIO m => Socket -> Int -> Server' Int ByteString m () Source #
Like fromSocket
, except the downstream pipe can specify the maximum
number of bytes to receive at once using request
.
fromSocketTimeoutN :: MonadIO m => Int -> Socket -> Int -> Server' Int ByteString m () Source #
Like fromSocketN
, except with the first Int
argument you can specify
the maximum time that each interaction with the remote end can take. If such
time elapses before the interaction finishes, then an IOError
exception is
thrown. The time is specified in microseconds (1 second = 1e6 microseconds).
Sending
The following consumers allow you to send bytes to the remote end.
Besides the consumers below, you might want to use Network.Simple.TCP's
send
, sendLazy
or sendMany
which happen to be Effect'
s:
send
::MonadIO
m =>Socket
->ByteString
->Effect'
m ()sendLazy
::MonadIO
m =>Socket
->ByteString
->Effect'
m ()sendMany
::MonadIO
m =>Socket
-> [ByteString
] ->Effect'
m ()
:: MonadIO m | |
=> Socket | Connected socket. |
-> Consumer' ByteString m r |
Sends to the remote end each ByteString
received from upstream.
:: MonadIO m | |
=> Socket | Connected socket. |
-> Consumer' ByteString m r |
Like toSocket
but takes a lazy ByteSring
and sends it in a more
efficient manner (compared to converting it to a strict ByteString
and
sending it).
:: MonadIO m | |
=> Socket | Connected socket. |
-> Consumer' [ByteString] m r |
Like toSocket
but takes a [
and sends it in a more
efficient manner (compared to converting it to a strict ByteSring
]ByteString
and
sending it).
toSocketTimeout :: MonadIO m => Int -> Socket -> Consumer' ByteString m r Source #
toSocketTimeoutLazy :: MonadIO m => Int -> Socket -> Consumer' ByteString m r Source #
Like toSocketTimeout
but takes a lazy ByteSring
and sends it in a
more efficient manner (compared to converting it to a strict ByteString
and sending it).
toSocketTimeoutMany :: MonadIO m => Int -> Socket -> Consumer' [ByteString] m r Source #
Like toSocketTimeout
but takes a [
and sends it in a
more efficient manner (compared to converting it to a strict ByteSring
]ByteString
and sending it).
Exports
module Network.Simple.TCP