zeromq4-haskell 0.1 → 0.2
raw patch · 5 files changed
+37/−3 lines, 5 files
Files
- src/System/ZMQ4.hs +7/−0
- src/System/ZMQ4/Base.hsc +3/−0
- src/System/ZMQ4/Monadic.hs +4/−0
- tests/System/ZMQ4/Test/Properties.hs +21/−1
- zeromq4-haskell.cabal +2/−2
src/System/ZMQ4.hs view
@@ -75,6 +75,7 @@ , bind , unbind , connect+ , disconnect , send , send' , sendMulti@@ -770,6 +771,12 @@ connect :: Socket a -> String -> IO () connect sock str = onSocket "connect" sock $ throwIfMinus1Retry_ "connect" . withCString str . c_zmq_connect++-- | Disconnect the socket from the given endpoint+-- (cf. <http://api.zeromq.org/4-0:zmq-disconnect zmq_disconnect>).+disconnect :: Socket a -> String -> IO ()+disconnect sock str = onSocket "disconnect" sock $+ throwIfMinus1Retry_ "disconnect" . withCString str . c_zmq_disconnect -- | Send the given 'SB.ByteString' over the socket -- (cf. <http://api.zeromq.org/4-0:zmq-sendmsg zmq_sendmsg>).
src/System/ZMQ4/Base.hsc view
@@ -318,6 +318,9 @@ foreign import ccall unsafe "zmq.h zmq_connect" c_zmq_connect :: ZMQSocket -> CString -> IO CInt +foreign import ccall unsafe "zmq.h zmq_disconnect"+ c_zmq_disconnect :: ZMQSocket -> CString -> IO CInt+ foreign import ccall unsafe "zmq.h zmq_sendmsg" c_zmq_sendmsg :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt
src/System/ZMQ4/Monadic.hs view
@@ -69,6 +69,7 @@ , bind , unbind , connect+ , disconnect , send , send' , sendMulti@@ -322,6 +323,9 @@ connect :: Socket z t -> String -> ZMQ z () connect s = liftIO . Z.connect (_unsocket s)++disconnect :: Socket z t -> String -> ZMQ z ()+disconnect s = liftIO . Z.disconnect (_unsocket s) send :: Z.Sender t => Socket z t -> [Z.Flag] -> ByteString -> ZMQ z () send s f = liftIO . Z.send (_unsocket s) f
tests/System/ZMQ4/Test/Properties.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE GADTs #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module System.ZMQ4.Test.Properties where@@ -46,7 +47,12 @@ , ("set;get socket option (Pull)", property $ prop_set_get_socket_option Pull) , ("set;get socket option (Push)", property $ prop_set_get_socket_option Push) , ("(un-)subscribe", property $ prop_subscribe Sub)- ])+ ] +++ [ ("connect disconnect ", property $ prop_connect_disconnect x) |+ x <- [ (AnySocket Rep, AnySocket Req)+ , (AnySocket Router, AnySocket Req)+ , (AnySocket Pull, AnySocket Push)]]+ ) quickBatch' ("0MQ Messages" , [ ("msg send == msg received (Req/Rep)", property $ prop_send_receive Req Rep)@@ -124,6 +130,16 @@ receive sub assert (msg == msg') ++prop_connect_disconnect :: (AnySocket, AnySocket) -> Property+prop_connect_disconnect (AnySocket t0, AnySocket t) = monadicIO $ run $+ runZMQ $ do+ s0 <- socket t0+ bind s0 "inproc://endpoint"+ s <- socket t+ connect s "inproc://endpoint"+ disconnect s "inproc://endpoint"+ instance Arbitrary ByteString where arbitrary = CB.pack . filter (/= '\0') <$> arbitrary @@ -192,3 +208,7 @@ toRneg1' :: Int64 -> Restricted (Nneg1, Int64) Int64 toRneg1' = fromJust . toRestricted . fromIntegral++data AnySocket where+ AnySocket :: SocketType a => a -> AnySocket+
zeromq4-haskell.cabal view
@@ -1,12 +1,12 @@ name: zeromq4-haskell-version: 0.1+version: 0.2 synopsis: Bindings to ZeroMQ 4.x category: System, FFI license: MIT license-file: LICENSE author: Toralf Wittner maintainer: Toralf Wittner <tw@dtex.org>-copyright: Copyright (c) 2010 - 2013 zeromq-haskell authors+copyright: Copyright (c) 2010 - 2014 zeromq-haskell authors homepage: http://github.com/twittner/zeromq-haskell/ stability: experimental tested-With: GHC == 7.6.3