ffi-rzmq 0.9.3 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +51 -0
- data/README.rdoc +17 -7
- data/examples/v2api/local_lat_poll.rb +3 -3
- data/examples/v2api/local_throughput.rb +2 -2
- data/examples/v2api/pub.rb +46 -0
- data/examples/v2api/publish_subscribe.rb +1 -1
- data/examples/v2api/remote_throughput.rb +1 -1
- data/examples/v2api/reqrep_poll.rb +2 -2
- data/examples/v2api/request_response.rb +2 -2
- data/examples/v2api/sub.rb +74 -0
- data/examples/v2api/throughput_measurement.rb +3 -3
- data/examples/v2api/xreqxrep_poll.rb +5 -5
- data/examples/v3api/local_lat_poll.rb +3 -3
- data/examples/v3api/pub.rb +46 -0
- data/examples/v3api/publish_subscribe.rb +1 -1
- data/examples/v3api/reqrep_poll.rb +2 -2
- data/examples/v3api/sub.rb +69 -0
- data/examples/v3api/xreqxrep_poll.rb +5 -5
- data/ffi-rzmq.gemspec +2 -2
- data/lib/ffi-rzmq/constants.rb +56 -18
- data/lib/ffi-rzmq/context.rb +63 -24
- data/lib/ffi-rzmq/device.rb +19 -19
- data/lib/ffi-rzmq/libzmq.rb +109 -34
- data/lib/ffi-rzmq/message.rb +23 -2
- data/lib/ffi-rzmq/poll.rb +7 -9
- data/lib/ffi-rzmq/socket.rb +284 -518
- data/lib/ffi-rzmq/util.rb +42 -36
- data/lib/ffi-rzmq/version.rb +1 -1
- data/spec/context_spec.rb +20 -16
- data/spec/device_spec.rb +64 -76
- data/spec/multipart_spec.rb +0 -54
- data/spec/nonblocking_recv_spec.rb +119 -80
- data/spec/poll_spec.rb +93 -12
- data/spec/pushpull_spec.rb +65 -111
- data/spec/reqrep_spec.rb +45 -56
- data/spec/socket_spec.rb +104 -71
- data/spec/spec_helper.rb +52 -4
- metadata +155 -135
data/lib/ffi-rzmq/util.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
|
2
2
|
module ZMQ
|
3
3
|
|
4
|
-
#
|
5
|
-
# in the #Context, #Socket and #Poller classes.
|
4
|
+
# General utility methods.
|
6
5
|
#
|
7
|
-
|
6
|
+
class Util
|
8
7
|
|
9
8
|
# Returns true when +rc+ is greater than or equal to 0, false otherwise.
|
10
9
|
#
|
@@ -57,40 +56,15 @@ module ZMQ
|
|
57
56
|
|
58
57
|
resultcode_ok?(rc) ? random : nil
|
59
58
|
end
|
60
|
-
|
61
|
-
# Returns the proper flag value for non-blocking regardless of 0mq
|
62
|
-
# version.
|
63
|
-
#
|
64
|
-
if LibZMQ.version2?
|
65
|
-
|
66
|
-
def self.nonblocking_flag
|
67
|
-
NOBLOCK
|
68
|
-
end
|
69
|
-
|
70
|
-
elsif LibZMQ.version3?
|
71
|
-
|
72
|
-
def self.nonblocking_flag
|
73
|
-
DONTWAIT
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
# generate a random port between 10_000 and 65534
|
82
|
-
def self.random_port
|
83
|
-
rand(55534) + 10_000
|
84
|
-
end
|
85
|
-
|
59
|
+
|
86
60
|
# :doc:
|
87
|
-
# Called
|
61
|
+
# Called to verify whether there were any errors during
|
88
62
|
# operation. If any are found, raise the appropriate #ZeroMQError.
|
89
63
|
#
|
90
64
|
# When no error is found, this method returns +true+ which is behavior
|
91
65
|
# used internally by #send and #recv.
|
92
66
|
#
|
93
|
-
def error_check source, result_code
|
67
|
+
def self.error_check source, result_code
|
94
68
|
if -1 == result_code
|
95
69
|
raise_error source, result_code
|
96
70
|
end
|
@@ -99,23 +73,55 @@ module ZMQ
|
|
99
73
|
true
|
100
74
|
end
|
101
75
|
|
102
|
-
|
103
|
-
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
# generate a random port between 10_000 and 65534
|
80
|
+
def self.random_port
|
81
|
+
rand(55534) + 10_000
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.raise_error source, result_code
|
85
|
+
if context_error?(source)
|
104
86
|
raise ContextError.new source, result_code, ZMQ::Util.errno, ZMQ::Util.error_string
|
105
87
|
|
106
|
-
elsif
|
88
|
+
elsif message_error?(source)
|
107
89
|
raise MessageError.new source, result_code, ZMQ::Util.errno, ZMQ::Util.error_string
|
108
90
|
|
109
91
|
else
|
110
|
-
puts "else"
|
111
92
|
raise ZeroMQError.new source, result_code, -1,
|
112
93
|
"Source [#{source}] does not match any zmq_* strings, rc [#{result_code}], errno [#{ZMQ::Util.errno}], error_string [#{ZMQ::Util.error_string}]"
|
113
94
|
end
|
114
95
|
end
|
115
96
|
|
116
|
-
def eagain?
|
97
|
+
def self.eagain?
|
117
98
|
EAGAIN == ZMQ::Util.errno
|
118
99
|
end
|
100
|
+
|
101
|
+
if LibZMQ.version2?
|
102
|
+
def self.context_error?(source)
|
103
|
+
'zmq_init' == source ||
|
104
|
+
'zmq_socket' == source
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.message_error?(source)
|
108
|
+
['zmq_msg_init', 'zmq_msg_init_data', 'zmq_msg_copy', 'zmq_msg_move'].include?(source)
|
109
|
+
end
|
110
|
+
|
111
|
+
elsif LibZMQ.version3?
|
112
|
+
def self.context_error?(source)
|
113
|
+
'zmq_ctx_new' == source ||
|
114
|
+
'zmq_ctx_set' == source ||
|
115
|
+
'zmq_ctx_get' == source ||
|
116
|
+
'zmq_ctx_destory' == source ||
|
117
|
+
'zmq_ctx_set_monitor' == source
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.message_error?(source)
|
121
|
+
['zmq_msg_init', 'zmq_msg_init_data', 'zmq_msg_copy', 'zmq_msg_move', 'zmq_msg_close', 'zmq_msg_get',
|
122
|
+
'zmq_msg_more', 'zmq_msg_recv', 'zmq_msg_send', 'zmq_msg_set'].include?(source)
|
123
|
+
end
|
124
|
+
end # if LibZMQ.version...?
|
119
125
|
|
120
126
|
end # module Util
|
121
127
|
|
data/lib/ffi-rzmq/version.rb
CHANGED
data/spec/context_spec.rb
CHANGED
@@ -11,16 +11,12 @@ module ZMQ
|
|
11
11
|
include APIHelper
|
12
12
|
|
13
13
|
it "should return nil for negative io threads" do
|
14
|
-
LibZMQ.stub(:zmq_init => nil)
|
15
14
|
Context.create(-1).should be_nil
|
16
15
|
end
|
17
16
|
|
18
17
|
it "should default to requesting 1 i/o thread when no argument is passed" do
|
19
|
-
ctx =
|
20
|
-
ctx.
|
21
|
-
LibZMQ.should_receive(:zmq_init).with(1).and_return(ctx)
|
22
|
-
|
23
|
-
Context.create
|
18
|
+
ctx = Context.create
|
19
|
+
ctx.io_threads.should == 1
|
24
20
|
end
|
25
21
|
|
26
22
|
it "should set the :pointer accessor to non-nil" do
|
@@ -48,17 +44,13 @@ module ZMQ
|
|
48
44
|
context "when initializing with #new" do
|
49
45
|
include APIHelper
|
50
46
|
|
51
|
-
it "should raise
|
52
|
-
LibZMQ.stub(:zmq_init => nil)
|
47
|
+
it "should raise a ContextError exception for negative io threads" do
|
53
48
|
lambda { Context.new(-1) }.should raise_exception(ZMQ::ContextError)
|
54
49
|
end
|
55
50
|
|
56
51
|
it "should default to requesting 1 i/o thread when no argument is passed" do
|
57
|
-
ctx =
|
58
|
-
ctx.
|
59
|
-
LibZMQ.should_receive(:zmq_init).with(1).and_return(ctx)
|
60
|
-
|
61
|
-
Context.new
|
52
|
+
ctx = Context.new
|
53
|
+
ctx.io_threads.should == 1
|
62
54
|
end
|
63
55
|
|
64
56
|
it "should set the :pointer accessor to non-nil" do
|
@@ -78,16 +70,28 @@ module ZMQ
|
|
78
70
|
|
79
71
|
it "should define a finalizer on this object" do
|
80
72
|
ObjectSpace.should_receive(:define_finalizer)
|
81
|
-
|
73
|
+
Context.new 1
|
82
74
|
end
|
83
75
|
end # context initializing
|
84
76
|
|
85
77
|
|
86
78
|
context "when terminating" do
|
87
|
-
it "should
|
79
|
+
it "should set the context to nil when terminating the library's context" do
|
88
80
|
ctx = Context.new # can't use a shared context here because we are terminating it!
|
89
|
-
LibZMQ.should_receive(:zmq_term).with(ctx.pointer).and_return(0)
|
90
81
|
ctx.terminate
|
82
|
+
ctx.pointer.should be_nil
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should call the correct library function to terminate the context" do
|
86
|
+
ctx = Context.new
|
87
|
+
|
88
|
+
if LibZMQ.version2?
|
89
|
+
LibZMQ.should_receive(:zmq_term).and_return(0)
|
90
|
+
ctx.terminate
|
91
|
+
else
|
92
|
+
LibZMQ.should_receive(:zmq_ctx_destroy).with(ctx.pointer).and_return(0)
|
93
|
+
ctx.terminate
|
94
|
+
end
|
91
95
|
end
|
92
96
|
end # context terminate
|
93
97
|
|
data/spec/device_spec.rb
CHANGED
@@ -1,89 +1,77 @@
|
|
1
1
|
|
2
2
|
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
3
3
|
|
4
|
-
|
4
|
+
module ZMQ
|
5
|
+
describe Device do
|
6
|
+
include APIHelper
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
before(:all) do
|
9
|
+
@ctx = Context.new
|
10
|
+
poller_setup
|
11
|
+
@front_endpoint = "inproc://device_front_test"
|
12
|
+
@back_endpoint = "inproc://device_back_test"
|
13
|
+
@mutex = Mutex.new
|
14
|
+
end
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
16
|
+
after(:all) do
|
17
|
+
@ctx.terminate
|
18
|
+
end
|
13
19
|
|
14
|
-
|
15
|
-
|
20
|
+
def create_streamer
|
21
|
+
@device_thread = false
|
22
|
+
|
23
|
+
Thread.new do
|
24
|
+
back = @ctx.socket(ZMQ::PULL)
|
25
|
+
back.bind(@back_endpoint)
|
26
|
+
front = @ctx.socket(ZMQ::PUSH)
|
27
|
+
front.bind(@front_endpoint)
|
28
|
+
@mutex.synchronize { @device_thread = true }
|
29
|
+
Device.new(ZMQ::STREAMER, back, front)
|
30
|
+
back.close
|
31
|
+
front.close
|
16
32
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@frontport = bind_to_random_tcp_port(front)
|
25
|
-
Device.new(ZMQ::STREAMER, back, front)
|
26
|
-
back.close
|
27
|
-
front.close
|
33
|
+
end
|
34
|
+
|
35
|
+
def wait_for_device
|
36
|
+
loop do
|
37
|
+
can_break = false
|
38
|
+
@mutex.synchronize do
|
39
|
+
can_break = true if @device_thread
|
28
40
|
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should create a streamer device without error given valid opts" do
|
33
|
-
create_streamer
|
41
|
+
break if can_break
|
34
42
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should create a device without error given valid opts" do
|
46
|
+
create_streamer
|
47
|
+
wait_for_device
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be able to send messages through the device" do
|
51
|
+
create_streamer
|
52
|
+
wait_for_device
|
53
|
+
|
54
|
+
pusher = @ctx.socket(ZMQ::PUSH)
|
55
|
+
connect_to_inproc(pusher, @back_endpoint)
|
56
|
+
puller = @ctx.socket(ZMQ::PULL)
|
57
|
+
connect_to_inproc(puller, @front_endpoint)
|
58
|
+
|
59
|
+
poll_it_for_read(puller) do
|
44
60
|
pusher.send_string("hello")
|
45
|
-
sleep 0.5
|
46
|
-
res = ''
|
47
|
-
rc = puller.recv_string(res, ZMQ::NOBLOCK)
|
48
|
-
res.should == "hello"
|
49
|
-
|
50
|
-
pusher.close
|
51
|
-
puller.close
|
52
|
-
sleep 0.5
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should raise an ArgumentError when trying to pass non-socket objects into the device" do
|
56
|
-
lambda {
|
57
|
-
Device.new(ZMQ::STREAMER, 1,2)
|
58
|
-
}.should raise_exception(ArgumentError)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should be able to create a forwarder device without error" do
|
62
|
-
Thread.new do
|
63
|
-
back = @ctx.socket(ZMQ::SUB)
|
64
|
-
bind_to_random_tcp_port(back)
|
65
|
-
front = @ctx.socket(ZMQ::PUB)
|
66
|
-
bind_to_random_tcp_port(front)
|
67
|
-
Device.new(ZMQ::FORWARDER, back, front)
|
68
|
-
back.close
|
69
|
-
front.close
|
70
|
-
end
|
71
|
-
sleep 0.5
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should be able to create a queue device without error" do
|
75
|
-
Thread.new do
|
76
|
-
back = @ctx.socket(ZMQ::ROUTER)
|
77
|
-
bind_to_random_tcp_port(back)
|
78
|
-
front = @ctx.socket(ZMQ::DEALER)
|
79
|
-
bind_to_random_tcp_port(front)
|
80
|
-
Device.new(ZMQ::QUEUE, back, front)
|
81
|
-
back.close
|
82
|
-
front.close
|
83
|
-
end
|
84
|
-
sleep 0.5
|
85
61
|
end
|
62
|
+
|
63
|
+
res = ''
|
64
|
+
rc = puller.recv_string(res, ZMQ::NonBlocking)
|
65
|
+
res.should == "hello"
|
66
|
+
|
67
|
+
pusher.close
|
68
|
+
puller.close
|
86
69
|
end
|
87
|
-
end
|
88
70
|
|
89
|
-
|
71
|
+
it "should raise an ArgumentError when trying to pass non-socket objects into the device" do
|
72
|
+
lambda {
|
73
|
+
Device.new(ZMQ::STREAMER, 1,2)
|
74
|
+
}.should raise_exception(ArgumentError)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/spec/multipart_spec.rb
CHANGED
@@ -55,7 +55,6 @@ module ZMQ
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
if version2?
|
59
58
|
context "with identity" do
|
60
59
|
include APIHelper
|
61
60
|
|
@@ -104,59 +103,6 @@ module ZMQ
|
|
104
103
|
end
|
105
104
|
end
|
106
105
|
|
107
|
-
elsif LibZMQ.version3? # version3
|
108
|
-
|
109
|
-
context "with identity" do
|
110
|
-
include APIHelper
|
111
|
-
|
112
|
-
before(:each) do # was :all
|
113
|
-
@rep = Socket.new(@ctx.pointer, ZMQ::ROUTER)
|
114
|
-
port = bind_to_random_tcp_port(@rep)
|
115
|
-
|
116
|
-
@req = Socket.new(@ctx.pointer, ZMQ::DEALER)
|
117
|
-
@req.identity = 'foo'
|
118
|
-
@req.connect("tcp://127.0.0.1:#{port}")
|
119
|
-
end
|
120
|
-
|
121
|
-
after(:each) do # was :all
|
122
|
-
@req.close
|
123
|
-
@rep.close
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should be delivered between ROUTER and DEALER returning an array of strings" do
|
127
|
-
req_data, rep_data = "hello", [ @req.identity, "ok" ]
|
128
|
-
|
129
|
-
@req.send_string(req_data)
|
130
|
-
strings = []
|
131
|
-
rc = @rep.recv_strings(strings)
|
132
|
-
strings.should == [ @req.identity, "hello" ]
|
133
|
-
|
134
|
-
@rep.send_strings(rep_data)
|
135
|
-
string = ''
|
136
|
-
rc = @req.recv_string(string)
|
137
|
-
string.should == rep_data.last
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should be delivered between ROUTER and DEALER returning an array of messages" do
|
141
|
-
req_data, rep_data = "hello", [ @req.identity, "ok" ]
|
142
|
-
|
143
|
-
@req.send_string(req_data)
|
144
|
-
msgs = []
|
145
|
-
rc = @rep.recvmsgs(msgs)
|
146
|
-
msgs[0].copy_out_string.should == @req.identity
|
147
|
-
msgs[1].copy_out_string.should == "hello"
|
148
|
-
|
149
|
-
@rep.send_strings(rep_data)
|
150
|
-
msgs = []
|
151
|
-
rc = @req.recvmsgs(msgs)
|
152
|
-
msgs[0].copy_out_string.should == rep_data.last
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
end # if version...
|
158
|
-
|
159
|
-
|
160
106
|
end
|
161
107
|
end
|
162
108
|
end
|
@@ -5,32 +5,26 @@ module ZMQ
|
|
5
5
|
|
6
6
|
|
7
7
|
describe Socket do
|
8
|
-
|
9
|
-
@ctx = Context.new
|
10
|
-
end
|
11
|
-
|
12
|
-
after(:all) do
|
13
|
-
@ctx.terminate
|
14
|
-
end
|
8
|
+
include APIHelper
|
15
9
|
|
16
10
|
|
17
11
|
shared_examples_for "any socket" do
|
18
12
|
|
19
13
|
it "returns -1 when there are no messages to read" do
|
20
14
|
array = []
|
21
|
-
rc = @receiver.recvmsgs(array,
|
15
|
+
rc = @receiver.recvmsgs(array, ZMQ::NonBlocking)
|
22
16
|
Util.resultcode_ok?(rc).should be_false
|
23
17
|
end
|
24
18
|
|
25
19
|
it "gets EAGAIN when there are no messages to read" do
|
26
20
|
array = []
|
27
|
-
rc = @receiver.recvmsgs(array,
|
21
|
+
rc = @receiver.recvmsgs(array, ZMQ::NonBlocking)
|
28
22
|
ZMQ::Util.errno.should == ZMQ::EAGAIN
|
29
23
|
end
|
30
24
|
|
31
25
|
it "returns the given array unmodified when there are no messages to read" do
|
32
26
|
array = []
|
33
|
-
rc = @receiver.recvmsgs(array,
|
27
|
+
rc = @receiver.recvmsgs(array, ZMQ::NonBlocking)
|
34
28
|
array.size.should be_zero
|
35
29
|
end
|
36
30
|
|
@@ -39,24 +33,26 @@ module ZMQ
|
|
39
33
|
shared_examples_for "sockets without exposed envelopes" do
|
40
34
|
|
41
35
|
it "read the single message and returns a successful result code" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
36
|
+
poll_it_for_read(@receiver) do
|
37
|
+
rc = @sender.send_string('test')
|
38
|
+
Util.resultcode_ok?(rc).should be_true
|
39
|
+
end
|
40
|
+
|
46
41
|
array = []
|
47
|
-
rc = @receiver.recvmsgs(array,
|
42
|
+
rc = @receiver.recvmsgs(array, ZMQ::NonBlocking)
|
48
43
|
Util.resultcode_ok?(rc).should be_true
|
49
44
|
array.size.should == 1
|
50
45
|
end
|
51
46
|
|
52
47
|
it "read all message parts transmitted and returns a successful result code" do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
poll_it_for_read(@receiver) do
|
49
|
+
strings = Array.new(10, 'test')
|
50
|
+
rc = @sender.send_strings(strings)
|
51
|
+
Util.resultcode_ok?(rc).should be_true
|
52
|
+
end
|
57
53
|
|
58
54
|
array = []
|
59
|
-
rc = @receiver.recvmsgs(array,
|
55
|
+
rc = @receiver.recvmsgs(array, ZMQ::NonBlocking)
|
60
56
|
Util.resultcode_ok?(rc).should be_true
|
61
57
|
array.size.should == 10
|
62
58
|
end
|
@@ -66,24 +62,26 @@ module ZMQ
|
|
66
62
|
shared_examples_for "sockets with exposed envelopes" do
|
67
63
|
|
68
64
|
it "read the single message and returns a successful result code" do
|
69
|
-
|
70
|
-
|
71
|
-
|
65
|
+
poll_it_for_read(@receiver) do
|
66
|
+
rc = @sender.send_string('test')
|
67
|
+
Util.resultcode_ok?(rc).should be_true
|
68
|
+
end
|
72
69
|
|
73
70
|
array = []
|
74
|
-
rc = @receiver.recvmsgs(array,
|
71
|
+
rc = @receiver.recvmsgs(array, ZMQ::NonBlocking)
|
75
72
|
Util.resultcode_ok?(rc).should be_true
|
76
73
|
array.size.should == 1 + 1 # extra 1 for envelope
|
77
74
|
end
|
78
75
|
|
79
76
|
it "read all message parts transmitted and returns a successful result code" do
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
poll_it_for_read(@receiver) do
|
78
|
+
strings = Array.new(10, 'test')
|
79
|
+
rc = @sender.send_strings(strings)
|
80
|
+
Util.resultcode_ok?(rc).should be_true
|
81
|
+
end
|
84
82
|
|
85
83
|
array = []
|
86
|
-
rc = @receiver.recvmsgs(array,
|
84
|
+
rc = @receiver.recvmsgs(array, ZMQ::NonBlocking)
|
87
85
|
Util.resultcode_ok?(rc).should be_true
|
88
86
|
array.size.should == 10 + 1 # add 1 for the envelope
|
89
87
|
end
|
@@ -96,21 +94,25 @@ module ZMQ
|
|
96
94
|
include APIHelper
|
97
95
|
|
98
96
|
before(:each) do
|
99
|
-
@
|
100
|
-
|
97
|
+
@context = Context.new
|
98
|
+
poller_setup
|
99
|
+
|
100
|
+
endpoint = "inproc://nonblocking_test"
|
101
|
+
@receiver = @context.socket ZMQ::SUB
|
101
102
|
assert_ok(@receiver.setsockopt(ZMQ::SUBSCRIBE, ''))
|
102
|
-
@sender = @
|
103
|
-
|
104
|
-
|
103
|
+
@sender = @context.socket ZMQ::PUB
|
104
|
+
@receiver.bind(endpoint)
|
105
|
+
connect_to_inproc(@sender, endpoint)
|
105
106
|
end
|
106
107
|
|
107
108
|
after(:each) do
|
108
109
|
@receiver.close
|
109
110
|
@sender.close
|
111
|
+
@context.terminate
|
110
112
|
end
|
111
113
|
|
112
114
|
it_behaves_like "any socket"
|
113
|
-
it_behaves_like "sockets without exposed envelopes"
|
115
|
+
#it_behaves_like "sockets without exposed envelopes" # see Jira LIBZMQ-270; fails with tcp transport
|
114
116
|
|
115
117
|
end # describe 'non-blocking recvmsgs'
|
116
118
|
|
@@ -118,21 +120,26 @@ module ZMQ
|
|
118
120
|
include APIHelper
|
119
121
|
|
120
122
|
before(:each) do
|
121
|
-
@
|
123
|
+
@context = Context.new
|
124
|
+
poller_setup
|
125
|
+
|
126
|
+
endpoint = "inproc://nonblocking_test"
|
127
|
+
@receiver = @context.socket ZMQ::SUB
|
122
128
|
port = connect_to_random_tcp_port(@receiver)
|
123
129
|
assert_ok(@receiver.setsockopt(ZMQ::SUBSCRIBE, ''))
|
124
|
-
@sender = @
|
125
|
-
|
126
|
-
|
130
|
+
@sender = @context.socket ZMQ::PUB
|
131
|
+
@sender.bind(endpoint)
|
132
|
+
connect_to_inproc(@receiver, endpoint)
|
127
133
|
end
|
128
134
|
|
129
135
|
after(:each) do
|
130
136
|
@receiver.close
|
131
137
|
@sender.close
|
138
|
+
@context.terminate
|
132
139
|
end
|
133
140
|
|
134
141
|
it_behaves_like "any socket"
|
135
|
-
it_behaves_like "sockets without exposed envelopes"
|
142
|
+
it_behaves_like "sockets without exposed envelopes" # see Jira LIBZMQ-270; fails with tcp transport
|
136
143
|
|
137
144
|
end # describe 'non-blocking recvmsgs'
|
138
145
|
|
@@ -144,16 +151,20 @@ module ZMQ
|
|
144
151
|
include APIHelper
|
145
152
|
|
146
153
|
before(:each) do
|
147
|
-
@
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
154
|
+
@context = Context.new
|
155
|
+
poller_setup
|
156
|
+
|
157
|
+
endpoint = "inproc://nonblocking_test"
|
158
|
+
@receiver = @context.socket ZMQ::REP
|
159
|
+
@sender = @context.socket ZMQ::REQ
|
160
|
+
@receiver.bind(endpoint)
|
161
|
+
connect_to_inproc(@sender, endpoint)
|
152
162
|
end
|
153
163
|
|
154
164
|
after(:each) do
|
155
165
|
@receiver.close
|
156
166
|
@sender.close
|
167
|
+
@context.terminate
|
157
168
|
end
|
158
169
|
|
159
170
|
it_behaves_like "any socket"
|
@@ -165,16 +176,20 @@ module ZMQ
|
|
165
176
|
include APIHelper
|
166
177
|
|
167
178
|
before(:each) do
|
168
|
-
@
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
179
|
+
@context = Context.new
|
180
|
+
poller_setup
|
181
|
+
|
182
|
+
endpoint = "inproc://nonblocking_test"
|
183
|
+
@receiver = @context.socket ZMQ::REP
|
184
|
+
@sender = @context.socket ZMQ::REQ
|
185
|
+
@sender.bind(endpoint)
|
186
|
+
connect_to_inproc(@receiver, endpoint)
|
173
187
|
end
|
174
188
|
|
175
189
|
after(:each) do
|
176
190
|
@receiver.close
|
177
191
|
@sender.close
|
192
|
+
@context.terminate
|
178
193
|
end
|
179
194
|
|
180
195
|
it_behaves_like "any socket"
|
@@ -191,16 +206,20 @@ module ZMQ
|
|
191
206
|
include APIHelper
|
192
207
|
|
193
208
|
before(:each) do
|
194
|
-
@
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
209
|
+
@context = Context.new
|
210
|
+
poller_setup
|
211
|
+
|
212
|
+
endpoint = "inproc://nonblocking_test"
|
213
|
+
@receiver = @context.socket ZMQ::PULL
|
214
|
+
@sender = @context.socket ZMQ::PUSH
|
215
|
+
@receiver.bind(endpoint)
|
216
|
+
connect_to_inproc(@sender, endpoint)
|
199
217
|
end
|
200
218
|
|
201
219
|
after(:each) do
|
202
220
|
@receiver.close
|
203
221
|
@sender.close
|
222
|
+
@context.terminate
|
204
223
|
end
|
205
224
|
|
206
225
|
it_behaves_like "any socket"
|
@@ -212,16 +231,20 @@ module ZMQ
|
|
212
231
|
include APIHelper
|
213
232
|
|
214
233
|
before(:each) do
|
215
|
-
@
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
234
|
+
@context = Context.new
|
235
|
+
poller_setup
|
236
|
+
|
237
|
+
endpoint = "inproc://nonblocking_test"
|
238
|
+
@receiver = @context.socket ZMQ::PULL
|
239
|
+
@sender = @context.socket ZMQ::PUSH
|
240
|
+
@sender.bind(endpoint)
|
241
|
+
connect_to_inproc(@receiver, endpoint)
|
220
242
|
end
|
221
243
|
|
222
244
|
after(:each) do
|
223
245
|
@receiver.close
|
224
246
|
@sender.close
|
247
|
+
@context.terminate
|
225
248
|
end
|
226
249
|
|
227
250
|
it_behaves_like "any socket"
|
@@ -238,16 +261,20 @@ module ZMQ
|
|
238
261
|
include APIHelper
|
239
262
|
|
240
263
|
before(:each) do
|
241
|
-
@
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
264
|
+
@context = Context.new
|
265
|
+
poller_setup
|
266
|
+
|
267
|
+
endpoint = "inproc://nonblocking_test"
|
268
|
+
@receiver = @context.socket ZMQ::ROUTER
|
269
|
+
@sender = @context.socket ZMQ::DEALER
|
270
|
+
@receiver.bind(endpoint)
|
271
|
+
connect_to_inproc(@sender, endpoint)
|
246
272
|
end
|
247
273
|
|
248
274
|
after(:each) do
|
249
275
|
@receiver.close
|
250
276
|
@sender.close
|
277
|
+
@context.terminate
|
251
278
|
end
|
252
279
|
|
253
280
|
it_behaves_like "any socket"
|
@@ -259,16 +286,20 @@ module ZMQ
|
|
259
286
|
include APIHelper
|
260
287
|
|
261
288
|
before(:each) do
|
262
|
-
@
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
289
|
+
@context = Context.new
|
290
|
+
poller_setup
|
291
|
+
|
292
|
+
endpoint = "inproc://nonblocking_test"
|
293
|
+
@receiver = @context.socket ZMQ::ROUTER
|
294
|
+
@sender = @context.socket ZMQ::DEALER
|
295
|
+
@sender.bind(endpoint)
|
296
|
+
connect_to_inproc(@receiver, endpoint)
|
267
297
|
end
|
268
298
|
|
269
299
|
after(:each) do
|
270
300
|
@receiver.close
|
271
301
|
@sender.close
|
302
|
+
@context.terminate
|
272
303
|
end
|
273
304
|
|
274
305
|
it_behaves_like "any socket"
|
@@ -285,16 +316,20 @@ module ZMQ
|
|
285
316
|
include APIHelper
|
286
317
|
|
287
318
|
before(:each) do
|
288
|
-
@
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
319
|
+
@context = Context.new
|
320
|
+
poller_setup
|
321
|
+
|
322
|
+
endpoint = "inproc://nonblocking_test"
|
323
|
+
@receiver = @context.socket ZMQ::XREP
|
324
|
+
@sender = @context.socket ZMQ::XREQ
|
325
|
+
@receiver.bind(endpoint)
|
326
|
+
connect_to_inproc(@sender, endpoint)
|
293
327
|
end
|
294
328
|
|
295
329
|
after(:each) do
|
296
330
|
@receiver.close
|
297
331
|
@sender.close
|
332
|
+
@context.terminate
|
298
333
|
end
|
299
334
|
|
300
335
|
it_behaves_like "any socket"
|
@@ -306,16 +341,20 @@ module ZMQ
|
|
306
341
|
include APIHelper
|
307
342
|
|
308
343
|
before(:each) do
|
309
|
-
@
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
344
|
+
@context = Context.new
|
345
|
+
poller_setup
|
346
|
+
|
347
|
+
endpoint = "inproc://nonblocking_test"
|
348
|
+
@receiver = @context.socket ZMQ::XREP
|
349
|
+
@sender = @context.socket ZMQ::XREQ
|
350
|
+
@sender.bind(endpoint)
|
351
|
+
connect_to_inproc(@receiver, endpoint)
|
314
352
|
end
|
315
353
|
|
316
354
|
after(:each) do
|
317
355
|
@receiver.close
|
318
356
|
@sender.close
|
357
|
+
@context.terminate
|
319
358
|
end
|
320
359
|
|
321
360
|
it_behaves_like "any socket"
|