ffi-rzmq 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +1 -1
  3. data/AUTHORS.txt +5 -1
  4. data/History.txt +19 -0
  5. data/README.rdoc +2 -4
  6. data/examples/README.rdoc +1 -3
  7. data/examples/{v3api/latency_measurement.rb → latency_measurement.rb} +1 -2
  8. data/examples/{v3api/local_lat.rb → local_lat.rb} +1 -1
  9. data/examples/{v3api/local_lat_poll.rb → local_lat_poll.rb} +4 -4
  10. data/examples/{v3api/local_throughput.rb → local_throughput.rb} +1 -1
  11. data/examples/{v3api/pub.rb → pub.rb} +1 -1
  12. data/examples/{v2api/publish_subscribe.rb → publish_subscribe.rb} +2 -2
  13. data/examples/{v2api/remote_lat.rb → remote_lat.rb} +1 -1
  14. data/examples/{v3api/remote_throughput.rb → remote_throughput.rb} +4 -3
  15. data/examples/{v2api/reqrep_poll.rb → reqrep_poll.rb} +3 -4
  16. data/examples/{v2api/request_response.rb → request_response.rb} +1 -2
  17. data/examples/{v3api/sub.rb → sub.rb} +1 -2
  18. data/examples/{v3api/throughput_measurement.rb → throughput_measurement.rb} +1 -1
  19. data/examples/{v3api/xreqxrep_poll.rb → xreqxrep_poll.rb} +6 -7
  20. data/ffi-rzmq.gemspec +4 -4
  21. data/lib/ffi-rzmq.rb +2 -3
  22. data/lib/ffi-rzmq/context.rb +25 -53
  23. data/lib/ffi-rzmq/device.rb +8 -4
  24. data/lib/ffi-rzmq/message.rb +24 -30
  25. data/lib/ffi-rzmq/poll.rb +5 -16
  26. data/lib/ffi-rzmq/socket.rb +129 -278
  27. data/lib/ffi-rzmq/util.rb +11 -36
  28. data/lib/ffi-rzmq/version.rb +1 -1
  29. data/spec/context_spec.rb +3 -8
  30. data/spec/device_spec.rb +10 -9
  31. data/spec/nonblocking_recv_spec.rb +7 -7
  32. data/spec/pushpull_spec.rb +8 -7
  33. data/spec/reqrep_spec.rb +6 -6
  34. data/spec/socket_spec.rb +43 -130
  35. data/spec/spec_helper.rb +3 -11
  36. metadata +77 -104
  37. data/examples/v2api/latency_measurement.rb +0 -139
  38. data/examples/v2api/local_lat.rb +0 -58
  39. data/examples/v2api/local_lat_poll.rb +0 -66
  40. data/examples/v2api/local_throughput.rb +0 -58
  41. data/examples/v2api/pub.rb +0 -46
  42. data/examples/v2api/remote_throughput.rb +0 -39
  43. data/examples/v2api/sub.rb +0 -74
  44. data/examples/v2api/throughput_measurement.rb +0 -138
  45. data/examples/v2api/xreqxrep_poll.rb +0 -93
  46. data/examples/v3api/publish_subscribe.rb +0 -82
  47. data/examples/v3api/remote_lat.rb +0 -71
  48. data/examples/v3api/reqrep_poll.rb +0 -62
  49. data/examples/v3api/request_response.rb +0 -40
  50. data/lib/ffi-rzmq/constants.rb +0 -187
  51. data/lib/ffi-rzmq/libc.rb +0 -19
  52. data/lib/ffi-rzmq/libzmq.rb +0 -283
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a406c4de564eef119c3f303a386546d6bfda94fd
4
+ data.tar.gz: 4ef6371ae1029809d302dc7911d0a5a056328428
5
+ SHA512:
6
+ metadata.gz: 801813a1a358e60fc0906369c1da88638bdb2c91588da12c50adf2b5869b8542690baa14b3d6098f2ba34e74fcb9468631c5f23ac21dba216782be21a654406d
7
+ data.tar.gz: 88e1a7bdc0500f6703e94ace2c145f96420fafa89b0bd39927edd5f4a396ca36a4a0bbb543d57b517b115eae5ffb9c55288b1b568fc4ae11f8acee903ceaa1b1
@@ -7,7 +7,7 @@ rvm:
7
7
  - ruby-head
8
8
  - jruby-19mode
9
9
  - jruby-head
10
- - rbx-19mode
10
+ - rbx-2.1.1
11
11
 
12
12
  matrix:
13
13
  allow_failures:
@@ -28,4 +28,8 @@ Simon Chiang , github: thinkerbot
28
28
 
29
29
  Harlow Ward, github: harlow
30
30
 
31
- Paul Chechetin, github: paulche
31
+ Paul Chechetin, github: paulche
32
+
33
+ Michael Zaccari, github: mzaccari
34
+
35
+ Jason Roelofs, github: jasonroelofs
@@ -1,3 +1,22 @@
1
+
2
+ == 2.0.0 / 20140108
3
+ * Split out all of the FFI code to its own gem so other projects can use
4
+ it without the effort of duplication.
5
+
6
+ * Support libzmq 4 API and its new security API . Thanks to Devin
7
+ Christensen (devin-c) and Jason Roelofs (jasonroelofs) for related
8
+ patches.
9
+
10
+ * Minor documentation fixes. Thanks to Michael Zaccari (mzaccari) for
11
+ the fix.
12
+
13
+ * Improved the readability of any FFI code (now moved to ffi-rzmq-core
14
+ project). Thanks to Stephen von Takach (stakach) for the patch.
15
+
16
+ * Updated AUTHORS.txt
17
+
18
+
19
+
1
20
  == 1.0.3 / 20131003
2
21
  * Fixes for issues #96 and #97. Thanks to Paul Chechetin (paulche) for
3
22
  the issues and patches.
@@ -122,17 +122,15 @@ I highly recommend visiting the Learn Ruby 0mq project for a bunch of good code
122
122
 
123
123
  == REQUIREMENTS:
124
124
 
125
- * 0mq 2.2.x, 3.2.x or later; 2.0.x, 3.0.x and 3.1.x are no longer supported
125
+ * 0mq 3.2.x, 4.x or later; 2.x, 3.0.x and 3.1.x are no longer supported
126
126
 
127
127
  The ZeroMQ library must be installed on your system in a well-known location
128
128
  like /usr/local/lib. This is the default for new ZeroMQ installs.
129
129
 
130
130
  If you have installed ZeroMQ using brew, you need to `brew link zeromq` before installing this gem.
131
131
 
132
- Future releases may include the library as a C extension built at
133
- time of installation.
134
-
135
132
  * ffi (>= 1.0.0)
133
+ * ffi-rzmq-core
136
134
 
137
135
  This is a requirement for MRI and Rubinius. JRuby has FFI support built
138
136
  in as a standard component. Do *not* run this gem under MRI with an old 'ffi' gem.
@@ -4,14 +4,12 @@
4
4
 
5
5
  1. lib dir
6
6
 
7
- All of the examples assume the lib directory containing the gem sources is two directories up from the location of the example.
7
+ All of the examples assume the lib directory containing the gem sources is one directory up from the location of the example.
8
8
 
9
9
  2. Installed libzmq library
10
10
 
11
11
  The ZeroMQ C libraries need to be downloaded, compiled and installed separately from the gem. Please see http://www.zeromq.org/area:download for links to the downloadable files along with some simple installation instructions. Also, be sure to check the FAQ if you run into problems with compiling.
12
12
 
13
- This gem auto-configures itself to conform to the API for 0mq 2.1.x and 3.1.x. The 0mq project started making backward-incompatible changes with the 3.x branch. Rather than create separate gems, this one handles all of them.
14
-
15
13
  It is possible to install the libzmq* files directly into the gem in the ext/ directory. This directory is checked for loadable libraries first before it falls back to checking the system paths.
16
14
 
17
15
  3. One terminal window
@@ -1,6 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
3
-
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
4
3
 
5
4
  # Within a single process, we start up two threads. One thread has a REQ (request)
6
5
  # socket and the second thread has a REP (reply) socket. We measure the
@@ -16,7 +16,7 @@
16
16
  # You should have received a copy of the Lesser GNU General Public License
17
17
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
19
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
20
20
 
21
21
  if ARGV.length < 3
22
22
  puts "usage: ruby local_lat.rb <connect-to> <message-size> <roundtrip-count>"
@@ -1,5 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
3
3
 
4
4
  if ARGV.length < 3
5
5
  puts "usage: ruby local_lat.rb <connect-to> <message-size> <roundtrip-count>"
@@ -38,7 +38,7 @@ start_time = Time.now
38
38
 
39
39
  # kick it off
40
40
  message = ZMQ::Message.new("a" * message_size)
41
- assert(s1.sendmsg(message, ZMQ::NonBlocking))
41
+ assert(s1.sendmsg(message, ZMQ::DONTWAIT))
42
42
 
43
43
  i = roundtrip_count
44
44
 
@@ -49,8 +49,8 @@ until i.zero?
49
49
 
50
50
  poller.readables.each do |socket|
51
51
  received_message = ''
52
- assert(socket.recv_string(received_message, ZMQ::NonBlocking))
53
- assert(socket.sendmsg(ZMQ::Message.new(received_message), ZMQ::NonBlocking))
52
+ assert(socket.recv_string(received_message, ZMQ::DONTWAIT))
53
+ assert(socket.sendmsg(ZMQ::Message.new(received_message), ZMQ::DONTWAIT))
54
54
  end
55
55
  end
56
56
 
@@ -1,5 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
3
3
 
4
4
  if ARGV.length != 3
5
5
  puts "usage: ruby local_throughtput.rb <bind-to> <message-size> <message-count>"
@@ -1,5 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
3
3
 
4
4
  if ARGV.length != 3
5
5
  puts "usage: ruby remote_throughput.rb <connect-to> <message-size> <message-count>"
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
2
2
 
3
3
 
4
4
  def assert(rc)
@@ -71,7 +71,7 @@ assert(s4.recv_string(body)) if s4.more_parts?
71
71
  puts "s4 received topic [#{topic}], body [#{body}]"
72
72
 
73
73
  s5_string = ''
74
- rc = s5.recv_string(s5_string, ZMQ::NonBlocking)
74
+ rc = s5.recv_string(s5_string, ZMQ::DONTWAIT)
75
75
  eagain = (rc == -1 && ZMQ::Util.errno == ZMQ::EAGAIN)
76
76
  puts(eagain ? "s5 received no messages" : "s5 FAILED")
77
77
 
@@ -17,7 +17,7 @@
17
17
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
19
 
20
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
20
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
21
21
 
22
22
  if ARGV.length < 3
23
23
  puts "usage: ruby remote_lat.rb <connect-to> <message-size> <roundtrip-count>"
@@ -1,5 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
3
3
 
4
4
  if ARGV.length != 3
5
5
  puts "usage: ruby remote_throughput.rb <connect-to> <message-size> <message-count>"
@@ -27,9 +27,10 @@ end
27
27
  #assert(s.setsockopt(ZMQ::SNDHWM, 0))
28
28
  assert(s.connect(connect_to))
29
29
 
30
- # the sleep gives the downstream SUB socket a chance to register its
30
+ # give the downstream SUB socket a chance to register its
31
31
  # subscription filters with this PUB socket
32
- sleep 1
32
+ puts "Hit any key to start publishing"
33
+ STDIN.gets
33
34
 
34
35
  contents = "#{'0'*message_size}"
35
36
 
@@ -1,6 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
3
-
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
4
3
 
5
4
  def assert(rc)
6
5
  raise "Last API call failed at #{caller(1)}" unless rc >= 0
@@ -38,7 +37,7 @@ until @done do
38
37
  payload = "#{ '3' * 1024 }"
39
38
 
40
39
  puts "sending payload nonblocking"
41
- assert(s1.send_string(payload, ZMQ::NonBlocking))
40
+ assert(s1.send_string(payload, ZMQ::DONTWAIT))
42
41
  @unsent = false
43
42
  end
44
43
 
@@ -46,7 +45,7 @@ until @done do
46
45
  if Time.now - start_time > 1
47
46
  poller.readables.each do |sock|
48
47
  received_msg = ''
49
- assert(sock.recv_string(received_msg, ZMQ::NonBlocking))
48
+ assert(sock.recv_string(received_msg, ZMQ::DONTWAIT))
50
49
 
51
50
  puts "message received [#{received_msg}]"
52
51
  @done = true
@@ -1,6 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
3
-
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
4
3
 
5
4
  def assert(rc)
6
5
  raise "Last API call failed at #{caller(1)}" unless rc >= 0
@@ -1,11 +1,10 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
3
3
 
4
4
  #if ARGV.length != 3
5
5
  # puts "usage: ruby local_throughtput.rb <bind-to> <message-size> <message-count>"
6
6
  # Process.exit
7
7
  #end
8
- p ZMQ::Util.version
9
8
 
10
9
  def assert(rc)
11
10
  raise "Last API call failed at #{caller(1)}" unless rc >= 0
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
2
2
  require 'thread'
3
3
 
4
4
  # Within a single process, we start up five threads. Main thread has a PUB (publisher)
@@ -1,6 +1,5 @@
1
1
 
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
3
-
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
4
3
 
5
4
  def assert(rc)
6
5
  raise "Last API call failed at #{caller(1)}" unless rc >= 0
@@ -43,7 +42,7 @@ until @done do
43
42
 
44
43
  5.times do |i|
45
44
  payload = "#{ i.to_s * 40 }"
46
- assert(s1.send_string(payload, ZMQ::NonBlocking))
45
+ assert(s1.send_string(payload, ZMQ::DONTWAIT))
47
46
  end
48
47
  @unsent = false
49
48
  end
@@ -54,12 +53,12 @@ until @done do
54
53
 
55
54
  if sock.identity =~ /xrep/
56
55
  routing_info = ''
57
- assert(sock.recv_string(routing_info, ZMQ::NonBlocking))
56
+ assert(sock.recv_string(routing_info, ZMQ::DONTWAIT))
58
57
  puts "routing_info received [#{routing_info}] on socket.identity [#{sock.identity}]"
59
58
  else
60
59
  routing_info = nil
61
60
  received_msg = ''
62
- assert(sock.recv_string(received_msg, ZMQ::NonBlocking))
61
+ assert(sock.recv_string(received_msg, ZMQ::DONTWAIT))
63
62
 
64
63
  # skip to the next iteration if received_msg is nil; that means we got an EAGAIN
65
64
  next unless received_msg
@@ -68,13 +67,13 @@ until @done do
68
67
 
69
68
  while sock.more_parts? do
70
69
  received_msg = ''
71
- assert(sock.recv_string(received_msg, ZMQ::NonBlocking))
70
+ assert(sock.recv_string(received_msg, ZMQ::DONTWAIT))
72
71
 
73
72
  puts "message received [#{received_msg}]"
74
73
  end
75
74
 
76
75
  puts "kick back a reply"
77
- assert(sock.send_string(routing_info, ZMQ::SNDMORE | ZMQ::NonBlocking)) if routing_info
76
+ assert(sock.send_string(routing_info, ZMQ::SNDMORE | ZMQ::DONTWAIT)) if routing_info
78
77
  time = Time.now.strftime "%Y-%m-%dT%H:%M:%S.#{Time.now.usec}"
79
78
  reply = "reply " + sock.identity.upcase + " #{time}"
80
79
  puts "sent reply [#{reply}], #{time}"
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
11
11
  s.summary = %q{This gem wraps the ZeroMQ (0mq) networking library using Ruby FFI (foreign function interface).}
12
12
  s.description = %q{This gem wraps the ZeroMQ networking library using the ruby FFI (foreign
13
13
  function interface). It's a pure ruby wrapper so this gem can be loaded
14
- and run by any ruby runtime that supports FFI. That's all of the major ones -
15
- MRI, Rubinius and JRuby.}
14
+ and run by any ruby runtime that supports FFI. That's all of the major ones - MRI, Rubinius and JRuby.}
16
15
 
16
+ s.license = 'MIT'
17
17
  s.rubyforge_project = "ffi-rzmq"
18
18
 
19
19
  s.files = `git ls-files`.split("\n")
@@ -21,7 +21,7 @@ MRI, Rubinius and JRuby.}
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_runtime_dependency "ffi"#, [">= 1.0.9"]
25
- s.add_development_dependency "rspec", ["~> 2.6"]
24
+ s.add_runtime_dependency "ffi-rzmq-core", [">= 1.0.1"]
25
+ s.add_development_dependency "rspec", ["~> 2.14"]
26
26
  s.add_development_dependency "rake"
27
27
  end
@@ -63,10 +63,9 @@ end # module ZMQ
63
63
  # some code is conditionalized based upon what ruby engine we are
64
64
  # executing
65
65
 
66
- require 'ffi'
66
+ require 'ffi-rzmq-core'
67
67
 
68
68
  # the order of files is important
69
- #%w(wrapper zmq exceptions context message socket poll_items poll device).each do |file|
70
- %w(libc libzmq constants util exceptions context message socket poll_items poll_item poll device).each do |file|
69
+ %w(util exceptions context message socket poll_items poll_item poll device).each do |file|
71
70
  require ZMQ.libpath(['ffi-rzmq', file])
72
71
  end
@@ -47,44 +47,29 @@ module ZMQ
47
47
 
48
48
  # Use the factory method Context#create to make contexts.
49
49
  #
50
- if LibZMQ.version2?
51
- def self.create io_threads = 1
52
- new(io_threads) rescue nil
53
- end
54
-
55
- def initialize io_threads = 1
56
- @io_threads = io_threads
57
- @context = LibZMQ.zmq_init io_threads
58
- ZMQ::Util.error_check 'zmq_init', (@context.nil? || @context.null?) ? -1 : 0
59
-
60
- define_finalizer
61
- end
62
- elsif LibZMQ.version3?
50
+ def self.create(opts = {})
51
+ new(opts) rescue nil
52
+ end
63
53
 
64
- def self.create(opts = {})
65
- new(opts) rescue nil
54
+ def initialize(opts = {})
55
+ if opts.respond_to?(:empty?)
56
+ @io_threads = opts[:io_threads] || IO_THREADS_DFLT
57
+ @max_sockets = opts[:max_sockets] || MAX_SOCKETS_DFLT
58
+ else
59
+ @io_threads = opts || 1
60
+ @max_sockets = MAX_SOCKETS_DFLT
66
61
  end
67
62
 
68
- def initialize(opts = {})
69
- if opts.respond_to?(:empty?)
70
- @io_threads = opts[:io_threads] || IO_THREADS_DFLT
71
- @max_sockets = opts[:max_sockets] || MAX_SOCKETS_DFLT
72
- else
73
- @io_threads = opts || 1
74
- @max_sockets = MAX_SOCKETS_DFLT
75
- end
76
-
77
- @context = LibZMQ.zmq_ctx_new
78
- ZMQ::Util.error_check 'zmq_ctx_new', (@context.nil? || @context.null?) ? -1 : 0
63
+ @context = LibZMQ.zmq_ctx_new
64
+ ZMQ::Util.error_check 'zmq_ctx_new', (@context.nil? || @context.null?) ? -1 : 0
79
65
 
80
- rc = LibZMQ.zmq_ctx_set(@context, ZMQ::IO_THREADS, @io_threads)
81
- ZMQ::Util.error_check 'zmq_ctx_set', rc
66
+ rc = LibZMQ.zmq_ctx_set(@context, ZMQ::IO_THREADS, @io_threads)
67
+ ZMQ::Util.error_check 'zmq_ctx_set', rc
82
68
 
83
- rc = LibZMQ.zmq_ctx_set(@context, ZMQ::MAX_SOCKETS, @max_sockets)
84
- ZMQ::Util.error_check 'zmq_ctx_set', rc
69
+ rc = LibZMQ.zmq_ctx_set(@context, ZMQ::MAX_SOCKETS, @max_sockets)
70
+ ZMQ::Util.error_check 'zmq_ctx_set', rc
85
71
 
86
- define_finalizer
87
- end
72
+ define_finalizer
88
73
  end
89
74
 
90
75
  # Call to release the context and any remaining data associated
@@ -94,27 +79,14 @@ module ZMQ
94
79
  #
95
80
  # Returns 0 for success, -1 for failure.
96
81
  #
97
- if LibZMQ.version2?
98
- def terminate
99
- unless @context.nil? || @context.null?
100
- remove_finalizer
101
- rc = LibZMQ.zmq_term @context
102
- @context = nil
103
- rc
104
- else
105
- 0
106
- end
107
- end
108
- elsif LibZMQ.version3?
109
- def terminate
110
- unless @context.nil? || @context.null?
111
- remove_finalizer
112
- rc = LibZMQ.zmq_ctx_destroy(@context)
113
- @context = nil
114
- rc
115
- else
116
- 0
117
- end
82
+ def terminate
83
+ unless @context.nil? || @context.null?
84
+ remove_finalizer
85
+ rc = LibZMQ.zmq_ctx_destroy(@context)
86
+ @context = nil
87
+ rc
88
+ else
89
+ 0
118
90
  end
119
91
  end
120
92
 
@@ -3,10 +3,10 @@ module ZMQ
3
3
  class Device
4
4
  attr_reader :device
5
5
 
6
- def self.create(device_type, frontend, backend)
6
+ def self.create(frontend, backend, capture=nil)
7
7
  dev = nil
8
8
  begin
9
- dev = new(device_type, frontend, backend)
9
+ dev = new(frontend, backend, capture)
10
10
  rescue ArgumentError
11
11
  dev = nil
12
12
  end
@@ -14,15 +14,19 @@ module ZMQ
14
14
  dev
15
15
  end
16
16
 
17
- def initialize(device_type, frontend, backend)
17
+ def initialize(frontend, backend, capture=nil)
18
18
  [["frontend", frontend], ["backend", backend]].each do |name, socket|
19
19
  unless socket.is_a?(ZMQ::Socket)
20
20
  raise ArgumentError, "Expected a ZMQ::Socket, not a #{socket.class} as the #{name}"
21
21
  end
22
22
  end
23
23
 
24
- LibZMQ.zmq_device(device_type, frontend.socket, backend.socket)
24
+ LibZMQ.zmq_proxy(frontend.socket, backend.socket, capture ? capture.socket : nil)
25
25
  end
26
26
  end
27
+
28
+ # Alias for Device
29
+ #
30
+ class Proxy < Device; end
27
31
 
28
32
  end