Skip to content

Instantly share code, notes, and snippets.

@danieldk
Created July 3, 2012 07:06
Show Gist options
  • Select an option

  • Save danieldk/3038189 to your computer and use it in GitHub Desktop.

Select an option

Save danieldk/3038189 to your computer and use it in GitHub Desktop.
ØMQ receive with timeout
receiveWithTimeout :: ZMQ.Socket a -> [ZMQ.Flag] -> ZMQ.Timeout ->
IO (Maybe B.ByteString)
receiveWithTimeout socket flags timeout = do
[ZMQ.S _ reqState] <- ZMQ.poll [ZMQ.S socket ZMQ.In] timeout
case reqState of
ZMQ.In -> Just <$> ZMQ.receive socket flags
_ -> return Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment