/examples/Haskell/rrclient.hs
Haskell | 26 lines | 14 code | 4 blank | 8 comment | 0 complexity | 8ff69e2dc6ff8bc95b0b935cad0b2341 MD5 | raw file
Possible License(s): BSD-3-Clause
- {-# LANGUAGE OverloadedStrings #-}
- -- |
- -- Request/Reply Hello World with broker (p.50)
- -- Binds REQ socket to tcp://localhost:5559
- -- Sends "Hello" to server, expects "World" back
- --
- -- Use with `rrbroker.hs` and `rrworker.hs`
- -- You need to start the broker first !
- module Main where
- import System.ZMQ4.Monadic
- import Control.Monad (forM_)
- import Data.ByteString.Char8 (unpack)
- import Text.Printf
- main :: IO ()
- main =
- runZMQ $ do
- requester <- socket Req
- connect requester "tcp://localhost:5559"
- forM_ [1..10] $ \i -> do
- send requester [] "Hello"
- msg <- receive requester
- liftIO $ printf "Received reply %d %s\n" (i ::Int) (unpack msg)