Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (21 sloc) 757 Bytes
-- |
-- Hello World server in Haskell
-- Binds REP socket to tcp://*:5560
-- Expects "Hello" from client, replies with "World"
--
-- Translated to Haskell by ERDI Gergo http://gergo.erdi.hu/
module Main where
import System.ZMQ
import Control.Monad (forever)
import Data.ByteString.Char8 (pack, unpack)
import Control.Concurrent (threadDelay)
main = withContext 1 $ \context -> do
withSocket context Rep $ \responder -> do
connect responder "tcp://localhost:5560"
forever $ do
message <- receive responder []
putStrLn $ unwords ["Received request:", unpack message]
-- Simulate doing some 'work' for 1 second
threadDelay (1 * 1000 * 1000)
send responder reply []
where reply = pack "World"
Something went wrong with that request. Please try again.