{-# LANGUAGE DeriveDataTypeable #-} module Main where import Control.Monad import System.ZMQ3 import System.Console.CmdArgs.Implicit data Echo = Echo { address :: String } deriving (Show, Data, Typeable) opts = Echo { address = def &= help "address to connect" } &= summary "Echo" main :: IO () main = do o <- cmdArgs opts withContext 2 $ \ctx -> withSocket ctx Rep $ \sck -> do bind sck (address o) forever $ receive sck >>= send sck []