ffi-rzmq 0.9.0 → 0.9.2

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.
@@ -0,0 +1,93 @@
1
+
2
+ require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
3
+
4
+
5
+ def assert(rc)
6
+ raise "Last API call failed at #{caller(1)}" unless rc >= 0
7
+ end
8
+
9
+ link = "tcp://127.0.0.1:5555"
10
+
11
+
12
+ begin
13
+ ctx = ZMQ::Context.new
14
+ s1 = ctx.socket(ZMQ::XREQ)
15
+ s2 = ctx.socket(ZMQ::XREP)
16
+ rescue ContextError => e
17
+ STDERR.puts "Failed to allocate context or socket"
18
+ raise
19
+ end
20
+
21
+ s1.identity = 'socket1.xreq'
22
+ s2.identity = 'socket2.xrep'
23
+
24
+ assert(s1.setsockopt(ZMQ::LINGER, 100))
25
+ assert(s2.setsockopt(ZMQ::LINGER, 100))
26
+
27
+ assert(s1.bind(link))
28
+ assert(s2.connect(link))
29
+
30
+ poller = ZMQ::Poller.new
31
+ poller.register_readable(s2)
32
+ poller.register_writable(s1)
33
+
34
+ start_time = Time.now
35
+ @unsent = true
36
+
37
+ until @done do
38
+ assert(poller.poll_nonblock)
39
+
40
+ # send the message after 5 seconds
41
+ if Time.now - start_time > 5 && @unsent
42
+ puts "sending payload nonblocking"
43
+
44
+ 5.times do |i|
45
+ payload = "#{ i.to_s * 40 }"
46
+ assert(s1.send_string(payload, ZMQ::DONTWAIT))
47
+ end
48
+ @unsent = false
49
+ end
50
+
51
+ # check for messages after 1 second
52
+ if Time.now - start_time > 1
53
+ poller.readables.each do |sock|
54
+
55
+ if sock.identity =~ /xrep/
56
+ routing_info = ''
57
+ assert(sock.recv_string(routing_info, ZMQ::DONTWAIT))
58
+ puts "routing_info received [#{routing_info}] on socket.identity [#{sock.identity}]"
59
+ else
60
+ routing_info = nil
61
+ received_msg = ''
62
+ assert(sock.recv_string(received_msg, ZMQ::DONTWAIT))
63
+
64
+ # skip to the next iteration if received_msg is nil; that means we got an EAGAIN
65
+ next unless received_msg
66
+ puts "message received [#{received_msg}] on socket.identity [#{sock.identity}]"
67
+ end
68
+
69
+ while sock.more_parts? do
70
+ received_msg = ''
71
+ assert(sock.recv_string(received_msg, ZMQ::DONTWAIT))
72
+
73
+ puts "message received [#{received_msg}]"
74
+ end
75
+
76
+ puts "kick back a reply"
77
+ assert(sock.send_string(routing_info, ZMQ::SNDMORE | ZMQ::DONTWAIT)) if routing_info
78
+ time = Time.now.strftime "%Y-%m-%dT%H:%M:%S.#{Time.now.usec}"
79
+ reply = "reply " + sock.identity.upcase + " #{time}"
80
+ puts "sent reply [#{reply}], #{time}"
81
+ assert(sock.send_string(reply))
82
+ @done = true
83
+ poller.register_readable(s1)
84
+ end
85
+ end
86
+ end
87
+
88
+ puts "executed in [#{Time.now - start_time}] seconds"
89
+
90
+ assert(s1.close)
91
+ assert(s2.close)
92
+
93
+ ctx.terminate
data/ffi-rzmq.gemspec CHANGED
@@ -1,36 +1,27 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ffi-rzmq/version"
2
4
 
3
5
  Gem::Specification.new do |s|
4
- s.name = %q{ffi-rzmq}
5
- s.version = "0.9.0"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Chuck Remes"]
9
- s.date = %q{2011-09-14}
6
+ s.name = "ffi-rzmq"
7
+ s.version = ZMQ::VERSION
8
+ s.authors = ["Chuck Remes"]
9
+ s.email = ["cremes@mac.com"]
10
+ s.homepage = "http://github.com/chuckremes/ffi-rzmq"
11
+ s.summary = %q{This gem wraps the ZeroMQ (0mq) networking library using Ruby FFI (foreign function interface).}
10
12
  s.description = %q{This gem wraps the ZeroMQ networking library using the ruby FFI (foreign
11
13
  function interface). It's a pure ruby wrapper so this gem can be loaded
12
14
  and run by any ruby runtime that supports FFI. That's all of them:
13
15
  MRI 1.9.x, Rubinius and JRuby.}
14
- s.email = %q{cremes@mac.com}
15
- s.extra_rdoc_files = ["AUTHORS.txt", "History.txt", "README.rdoc", "examples/README.rdoc", "version.txt"]
16
- s.files = [".bnsignore", "History.txt", "README.rdoc", "Rakefile", "examples/README.rdoc", "examples/v2api/local_lat.rb", "examples/v2api/local_lat_poll.rb", "examples/v2api/local_throughput.rb", "examples/v2api/publish_subscribe.rb", "examples/v2api/remote_lat.rb", "examples/v2api/remote_throughput.rb", "examples/v2api/reqrep_poll.rb", "examples/v2api/request_response.rb", "examples/v2api/throughput_measurement.rb", "examples/v3api/local_lat.rb", "examples/v3api/local_lat_poll.rb", "examples/v3api/local_throughput.rb", "examples/v3api/publish_subscribe.rb", "examples/v3api/remote_lat.rb", "examples/v3api/remote_throughput.rb", "examples/v3api/reqrep_poll.rb", "examples/v3api/request_response.rb", "examples/v3api/throughput_measurement.rb", "ext/README", "ffi-rzmq.gemspec", "lib/ffi-rzmq.rb", "lib/ffi-rzmq/constants.rb", "lib/ffi-rzmq/context.rb", "lib/ffi-rzmq/device.rb", "lib/ffi-rzmq/exceptions.rb", "lib/ffi-rzmq/libc.rb", "lib/ffi-rzmq/libzmq.rb", "lib/ffi-rzmq/message.rb", "lib/ffi-rzmq/poll.rb", "lib/ffi-rzmq/poll_items.rb", "lib/ffi-rzmq/socket.rb", "lib/ffi-rzmq/util.rb", "spec/context_spec.rb", "spec/device_spec.rb", "spec/message_spec.rb", "spec/multipart_spec.rb", "spec/nonblocking_recv_spec.rb", "spec/pushpull_spec.rb", "spec/reqrep_spec.rb", "spec/socket_spec.rb", "spec/spec_helper.rb", "version.txt"]
17
- s.homepage = %q{http://github.com/chuckremes/ffi-rzmq}
18
- s.rdoc_options = ["--main", "README.rdoc"]
19
- s.require_paths = ["lib"]
20
- s.rubyforge_project = %q{ffi-rzmq}
21
- s.rubygems_version = %q{1.3.7}
22
- s.summary = %q{This gem wraps the ZeroMQ (0mq) networking library using Ruby FFI (foreign function interface).}
23
16
 
24
- if s.respond_to? :specification_version then
25
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
- s.specification_version = 3
17
+ s.rubyforge_project = "ffi-rzmq"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
27
23
 
28
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
29
- s.add_development_dependency(%q<bones>, [">= 3.5.4"])
30
- else
31
- s.add_dependency(%q<bones>, [">= 3.5.4"])
32
- end
33
- else
34
- s.add_dependency(%q<bones>, [">= 3.5.4"])
35
- end
24
+ s.add_runtime_dependency "ffi", [">= 1.0.9"]
25
+ s.add_development_dependency "rspec", ["~> 2.6"]
26
+ s.add_development_dependency "rake"
36
27
  end
@@ -82,7 +82,7 @@ module ZMQ
82
82
  end # module ZMQ
83
83
 
84
84
 
85
- if LibZMQ.version2?
85
+ if ZMQ::LibZMQ.version2?
86
86
  module ZMQ
87
87
  # Socket types
88
88
  UPSTREAM = PULL
@@ -111,13 +111,13 @@ if LibZMQ.version2?
111
111
  end # version2?
112
112
 
113
113
 
114
- if LibZMQ.version3?
114
+ if ZMQ::LibZMQ.version3?
115
115
  module ZMQ
116
116
  # Socket types
117
117
  XPUB = 9
118
118
  XSUB = 10
119
- ROUTER = 11
120
- DEALER = 12
119
+ DEALER = XREQ
120
+ ROUTER = XREP
121
121
 
122
122
  SocketTypeNameMap[ROUTER] = 'ROUTER'
123
123
  SocketTypeNameMap[DEALER] = 'DEALER'
@@ -132,7 +132,6 @@ if LibZMQ.version3?
132
132
  MULTICAST_HOPS = 25
133
133
  RCVTIMEO = 27
134
134
  SNDTIMEO = 28
135
- RCVLABEL = 29
136
135
 
137
136
  # Send/recv options
138
137
  DONTWAIT = 1
@@ -144,35 +143,3 @@ if LibZMQ.version3?
144
143
 
145
144
  end
146
145
  end # version3?
147
-
148
-
149
- if LibZMQ.version4?
150
- module ZMQ
151
- # Socket types
152
- XPUB = 9
153
- XSUB = 10
154
- ROUTER = 13
155
-
156
- SocketTypeNameMap[ROUTER] = 'ROUTER'
157
- SocketTypeNameMap[XPUB] = 'XPUB'
158
- SocketTypeNameMap[XSUB] = 'XSUB'
159
-
160
- # Socket options
161
- MAXMSGSIZE = 22
162
- SNDHWM = 23
163
- RCVHWM = 24
164
- MULTICAST_HOPS = 25
165
- RCVTIMEO = 27
166
- SNDTIMEO = 28
167
- RCVLABEL = 29
168
-
169
- # Send/recv options
170
- DONTWAIT = 1
171
- SNDLABEL = 4
172
-
173
-
174
- # Socket & other errors
175
- EMFILE = Errno::EMFILE::Errno
176
-
177
- end
178
- end # version4?
@@ -1,188 +1,201 @@
1
+ module ZMQ
1
2
 
2
- # Wraps the libzmq library and attaches to the functions that are
3
- # common across the 2.x, 3.x and 4.x APIs.
4
- #
5
- module LibZMQ
6
- extend FFI::Library
7
-
8
- # bias the library discovery to a path inside the gem first, then
9
- # to the usual system paths
10
- inside_gem = File.join(File.dirname(__FILE__), '..', '..', 'ext')
11
- ZMQ_LIB_PATHS = [
12
- inside_gem, '/usr/local/lib', '/opt/local/lib', '/usr/local/homebrew/lib', '/usr/lib64'
13
- ].map{|path| "#{path}/libzmq.#{FFI::Platform::LIBSUFFIX}"}
14
- ffi_lib(ZMQ_LIB_PATHS + %w{libzmq})
3
+ # Wraps the libzmq library and attaches to the functions that are
4
+ # common across the 2.x, 3.x and 4.x APIs.
5
+ #
6
+ module LibZMQ
7
+ extend FFI::Library
8
+
9
+ begin
10
+ # bias the library discovery to a path inside the gem first, then
11
+ # to the usual system paths
12
+ inside_gem = File.join(File.dirname(__FILE__), '..', '..', 'ext')
13
+ ZMQ_LIB_PATHS = [
14
+ inside_gem, '/usr/local/lib', '/opt/local/lib', '/usr/local/homebrew/lib', '/usr/lib64'
15
+ ].map{|path| "#{path}/libzmq.#{FFI::Platform::LIBSUFFIX}"}
16
+ ffi_lib(ZMQ_LIB_PATHS + %w{libzmq})
17
+ rescue LoadError
18
+ STDERR.puts "Unable to load this gem. The libzmq library (or DLL) could not be found."
19
+ STDERR.puts "If this is a Windows platform, make sure libzmq.dll is on the PATH."
20
+ STDERR.puts "For non-Windows platforms, make sure libzmq is located in this search path:"
21
+ STDERR.puts ZMQ_LIB_PATHS.inspect
22
+ exit 255
23
+ end
15
24
 
16
- # Size_t not working properly on Windows
17
- find_type(:size_t) rescue typedef(:ulong, :size_t)
25
+ # Size_t not working properly on Windows
26
+ find_type(:size_t) rescue typedef(:ulong, :size_t)
27
+
28
+ # Context and misc api
29
+ #
30
+ # @blocking = true is a hint to FFI that the following (and only the following)
31
+ # function may block, therefore it should release the GIL before calling it.
32
+ # This can aid in situations where the function call will/may block and another
33
+ # thread within the lib may try to call back into the ruby runtime. Failure to
34
+ # release the GIL will result in a hang; the hint *may* allow things to run
35
+ # smoothly for Ruby runtimes hampered by a GIL.
36
+ #
37
+ # This is really only honored by the MRI implementation but it *is* necessary
38
+ # otherwise the runtime hangs (and requires a kill -9 to terminate)
39
+ #
40
+ @blocking = true
41
+ attach_function :zmq_init, [:int], :pointer
42
+ @blocking = true
43
+ attach_function :zmq_socket, [:pointer, :int], :pointer
44
+ @blocking = true
45
+ attach_function :zmq_term, [:pointer], :int
46
+ @blocking = true
47
+ attach_function :zmq_errno, [], :int
48
+ @blocking = true
49
+ attach_function :zmq_strerror, [:int], :pointer
50
+ @blocking = true
51
+ attach_function :zmq_version, [:pointer, :pointer, :pointer], :void
52
+
53
+ def self.version
54
+ unless @version
55
+ major = FFI::MemoryPointer.new :int
56
+ minor = FFI::MemoryPointer.new :int
57
+ patch = FFI::MemoryPointer.new :int
58
+ LibZMQ.zmq_version major, minor, patch
59
+ @version = {:major => major.read_int, :minor => minor.read_int, :patch => patch.read_int}
60
+ end
18
61
 
19
- # Context and misc api
20
- #
21
- # @blocking = true is a hint to FFI that the following (and only the following)
22
- # function may block, therefore it should release the GIL before calling it.
23
- # This can aid in situations where the function call will/may block and another
24
- # thread within the lib may try to call back into the ruby runtime. Failure to
25
- # release the GIL will result in a hang; the hint *may* allow things to run
26
- # smoothly for Ruby runtimes hampered by a GIL.
27
- #
28
- # This is really only honored by the MRI implementation but it *is* necessary
29
- # otherwise the runtime hangs (and requires a kill -9 to terminate)
30
- #
31
- @blocking = true
32
- attach_function :zmq_init, [:int], :pointer
33
- @blocking = true
34
- attach_function :zmq_socket, [:pointer, :int], :pointer
35
- @blocking = true
36
- attach_function :zmq_term, [:pointer], :int
37
- @blocking = true
38
- attach_function :zmq_errno, [], :int
39
- @blocking = true
40
- attach_function :zmq_strerror, [:int], :pointer
41
- @blocking = true
42
- attach_function :zmq_version, [:pointer, :pointer, :pointer], :void
43
-
44
- def self.version
45
- unless @version
46
- major = FFI::MemoryPointer.new :int
47
- minor = FFI::MemoryPointer.new :int
48
- patch = FFI::MemoryPointer.new :int
49
- LibZMQ.zmq_version major, minor, patch
50
- @version = {:major => major.read_int, :minor => minor.read_int, :patch => patch.read_int}
62
+ @version
51
63
  end
52
64
 
53
- @version
54
- end
65
+ def self.version2?() version[:major] == 2 && version[:minor] >= 1 end
55
66
 
56
- def self.version2?() version[:major] == 2 && version[:minor] >= 1 end
67
+ def self.version3?() version[:major] == 3 && version[:minor] >= 1 end
57
68
 
58
- def self.version3?() version[:major] == 3 end
69
+ def self.version4?() version[:major] == 4 end
59
70
 
60
- def self.version4?() version[:major] == 4 end
61
71
 
72
+ # Message api
73
+ @blocking = true
74
+ attach_function :zmq_msg_init, [:pointer], :int
75
+ @blocking = true
76
+ attach_function :zmq_msg_init_size, [:pointer, :size_t], :int
77
+ @blocking = true
78
+ attach_function :zmq_msg_init_data, [:pointer, :pointer, :size_t, :pointer, :pointer], :int
79
+ @blocking = true
80
+ attach_function :zmq_msg_close, [:pointer], :int
81
+ @blocking = true
82
+ attach_function :zmq_msg_data, [:pointer], :pointer
83
+ @blocking = true
84
+ attach_function :zmq_msg_size, [:pointer], :size_t
85
+ @blocking = true
86
+ attach_function :zmq_msg_copy, [:pointer, :pointer], :int
87
+ @blocking = true
88
+ attach_function :zmq_msg_move, [:pointer, :pointer], :int
62
89
 
63
- # Message api
64
- @blocking = true
65
- attach_function :zmq_msg_init, [:pointer], :int
66
- @blocking = true
67
- attach_function :zmq_msg_init_size, [:pointer, :size_t], :int
68
- @blocking = true
69
- attach_function :zmq_msg_init_data, [:pointer, :pointer, :size_t, :pointer, :pointer], :int
70
- @blocking = true
71
- attach_function :zmq_msg_close, [:pointer], :int
72
- @blocking = true
73
- attach_function :zmq_msg_data, [:pointer], :pointer
74
- @blocking = true
75
- attach_function :zmq_msg_size, [:pointer], :size_t
76
- @blocking = true
77
- attach_function :zmq_msg_copy, [:pointer, :pointer], :int
78
- @blocking = true
79
- attach_function :zmq_msg_move, [:pointer, :pointer], :int
90
+ # Used for casting pointers back to the struct
91
+ #
92
+ class Msg < FFI::Struct
93
+ layout :content, :pointer,
94
+ :flags, :uint8,
95
+ :vsm_size, :uint8,
96
+ :vsm_data, [:uint8, 30]
97
+ end # class Msg
80
98
 
81
- # Used for casting pointers back to the struct
82
- #
83
- class Msg < FFI::Struct
84
- layout :content, :pointer,
85
- :flags, :uint8,
86
- :vsm_size, :uint8,
87
- :vsm_data, [:uint8, 30]
88
- end # class Msg
89
-
90
- # Socket api
91
- @blocking = true
92
- attach_function :zmq_setsockopt, [:pointer, :int, :pointer, :int], :int
93
- @blocking = true
94
- attach_function :zmq_bind, [:pointer, :string], :int
95
- @blocking = true
96
- attach_function :zmq_connect, [:pointer, :string], :int
97
- @blocking = true
98
- attach_function :zmq_close, [:pointer], :int
99
-
100
- # Poll api
101
- @blocking = true
102
- attach_function :zmq_poll, [:pointer, :int, :long], :int
103
-
104
- module PollItemLayout
105
- def self.included(base)
106
- base.class_eval do
107
- layout :socket, :pointer,
108
- :fd, :int,
109
- :events, :short,
110
- :revents, :short
111
- end
112
- end
113
- end # module PollItemLayout
99
+ # Socket api
100
+ @blocking = true
101
+ attach_function :zmq_setsockopt, [:pointer, :int, :pointer, :int], :int
102
+ @blocking = true
103
+ attach_function :zmq_bind, [:pointer, :string], :int
104
+ @blocking = true
105
+ attach_function :zmq_connect, [:pointer, :string], :int
106
+ @blocking = true
107
+ attach_function :zmq_close, [:pointer], :int
114
108
 
115
- class PollItem < FFI::Struct
116
- include PollItemLayout
109
+ # Poll api
110
+ @blocking = true
111
+ attach_function :zmq_poll, [:pointer, :int, :long], :int
112
+
113
+ module PollItemLayout
114
+ def self.included(base)
115
+ base.class_eval do
116
+ layout :socket, :pointer,
117
+ :fd, :int,
118
+ :events, :short,
119
+ :revents, :short
120
+ end
121
+ end
122
+ end # module PollItemLayout
117
123
 
118
- def socket() self[:socket]; end
124
+ class PollItem < FFI::Struct
125
+ include PollItemLayout
119
126
 
120
- def readable?
121
- (self[:revents] & ZMQ::POLLIN) > 0
122
- end
127
+ def socket() self[:socket]; end
128
+
129
+ def fd() self[:fd]; end
123
130
 
124
- def writable?
125
- (self[:revents] & ZMQ::POLLOUT) > 0
126
- end
131
+ def readable?
132
+ (self[:revents] & ZMQ::POLLIN) > 0
133
+ end
127
134
 
128
- def both_accessible?
129
- readable? && writable?
130
- end
135
+ def writable?
136
+ (self[:revents] & ZMQ::POLLOUT) > 0
137
+ end
131
138
 
132
- def inspect
133
- "socket [#{socket}], fd [#{self[:fd]}], events [#{self[:events]}], revents [#{self[:revents]}]"
134
- end
139
+ def both_accessible?
140
+ readable? && writable?
141
+ end
135
142
 
136
- def to_s; inspect; end
137
- end # class PollItem
143
+ def inspect
144
+ "socket [#{socket}], fd [#{fd}], events [#{self[:events]}], revents [#{self[:revents]}]"
145
+ end
138
146
 
139
- end
147
+ def to_s; inspect; end
148
+ end # class PollItem
140
149
 
150
+ end
141
151
 
142
- # Attaches to those functions specific to the 2.x API
143
- #
144
- if LibZMQ.version2?
145
152
 
146
- module LibZMQ
147
- # Socket api
148
- @blocking = true
149
- attach_function :zmq_getsockopt, [:pointer, :int, :pointer, :pointer], :int
150
- @blocking = true
151
- attach_function :zmq_recv, [:pointer, :pointer, :int], :int
152
- @blocking = true
153
- attach_function :zmq_send, [:pointer, :pointer, :int], :int
154
- @blocking = true
155
- attach_function :zmq_device, [:int, :pointer, :pointer], :int
153
+ # Attaches to those functions specific to the 2.x API
154
+ #
155
+ if LibZMQ.version2?
156
+
157
+ module LibZMQ
158
+ # Socket api
159
+ @blocking = true
160
+ attach_function :zmq_getsockopt, [:pointer, :int, :pointer, :pointer], :int
161
+ @blocking = true
162
+ attach_function :zmq_recv, [:pointer, :pointer, :int], :int
163
+ @blocking = true
164
+ attach_function :zmq_send, [:pointer, :pointer, :int], :int
165
+ @blocking = true
166
+ attach_function :zmq_device, [:int, :pointer, :pointer], :int
167
+ end
156
168
  end
157
- end
158
169
 
159
170
 
160
- # Attaches to those functions specific to the 3.x API
161
- #
162
- if LibZMQ.version3? || LibZMQ.version4?
171
+ # Attaches to those functions specific to the 3.x API
172
+ #
173
+ if LibZMQ.version3?
174
+
175
+ module LibZMQ
176
+ # Socket api
177
+ @blocking = true
178
+ attach_function :zmq_getsockopt, [:pointer, :int, :pointer, :pointer], :int
179
+ @blocking = true
180
+ attach_function :zmq_recvmsg, [:pointer, :pointer, :int], :int
181
+ @blocking = true
182
+ attach_function :zmq_recv, [:pointer, :pointer, :size_t, :int], :int
183
+ @blocking = true
184
+ attach_function :zmq_sendmsg, [:pointer, :pointer, :int], :int
185
+ @blocking = true
186
+ attach_function :zmq_send, [:pointer, :pointer, :size_t, :int], :int
187
+ end
188
+ end
163
189
 
164
- module LibZMQ
165
- # Socket api
166
- @blocking = true
167
- attach_function :zmq_getsockopt, [:pointer, :int, :pointer, :pointer], :int
168
- @blocking = true
169
- attach_function :zmq_recvmsg, [:pointer, :pointer, :int], :int
170
- @blocking = true
171
- attach_function :zmq_recv, [:pointer, :pointer, :size_t, :int], :int
172
- @blocking = true
173
- attach_function :zmq_sendmsg, [:pointer, :pointer, :int], :int
174
- @blocking = true
175
- attach_function :zmq_send, [:pointer, :pointer, :size_t, :int], :int
190
+
191
+ # Sanity check; print an error and exit if we are trying to load an unsupported
192
+ # version of libzmq.
193
+ #
194
+ unless LibZMQ.version2? || LibZMQ.version3?
195
+ hash = LibZMQ.version
196
+ version = "#{hash[:major]}.#{hash[:minor]}.#{hash[:patch]}"
197
+ STDERR.puts "Unable to load this gem. The libzmq version #{version} is incompatible with ffi-rzmq."
198
+ exit 255
176
199
  end
177
- end
178
-
179
-
180
- # Sanity check; print an error and exit if we are trying to load an unsupported
181
- # version of libzmq.
182
- #
183
- unless LibZMQ.version2? || LibZMQ.version3? || LibZMQ.version4?
184
- hash = LibZMQ.version
185
- version = "#{hash[:major]}.#{hash[:minor]}.#{hash[:patch]}"
186
- STDERR.puts "Unable to load this gem. The libzmq version #{version} is incompatible with ffi-rzmq."
187
- exit 255
188
- end
200
+
201
+ end # module ZMQ