Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Box.TCP.Example
Description
It's a box. It's a TCP socket. It's an example.
Synopsis
- senderExample :: [ByteString] -> IO [ByteString]
- senderLinesExample :: [Text] -> IO [Text]
- echoExample :: [ByteString] -> IO [ByteString]
- clientIO :: IO ()
- serverIO :: IO ()
Documentation
>>>
:set -XOverloadedStrings
>>>
import Box
>>>
import Box.TCP.Example
>>>
import Control.Concurrent.Async
senderExample :: [ByteString] -> IO [ByteString] Source #
A server that only sends and a client that only receives.
The result here is indeterminate: it can return ["ab"] or ["a","b"] depending on when the client and servers fire.
senderExample ["a","b"]
- "ab"
senderLinesExample :: [Text] -> IO [Text] Source #
A server that only sends and a client that only receives.
>>>
senderLinesExample ["a","b"]
["a","b"]
echoExample :: [ByteString] -> IO [ByteString] Source #
echo server example
>>>
echoExample ["a","b","c"]
["echo: abc"]
"q" to close the client, reads and writes from std
>>>
clientIO
*** Exception: Network.Socket.connect: <socket: ...>: does not exist (Connection refused)