Skip to content

Instantly share code, notes, and snippets.

@johnbender
Created August 21, 2010 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbender/542102 to your computer and use it in GitHub Desktop.
Save johnbender/542102 to your computer and use it in GitHub Desktop.
-- rcv.hs
import System.ZMQ as ZMQ
import Control.Monad
main = do context <- ZMQ.init 1
sock <- socket context Sub
subscribe sock ""
connect sock "tcp://localhost:5555"
forever $ do
str <- receive sock []
print str
-- snd.hs
import System.ZMQ as ZMQ
import Control.Monad
import Data.ByteString.Lazy hiding (map)
import Data.ByteString.Internal
main = do context <- ZMQ.init 1
sock <- socket context Pub
bind sock "tcp://127.0.0.1:5555"
-- 99% sure there's a better way to do this
forever $ send' sock (pack $ map c2w "Foo") []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment