ffi-rzmq 1.0.3 → 2.0.4
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.
- checksums.yaml +7 -0
- data/.travis.yml +1 -1
- data/AUTHORS.txt +5 -1
- data/History.txt +45 -0
- data/README.rdoc +58 -28
- data/Rakefile +15 -0
- data/examples/README.rdoc +1 -3
- data/examples/{v3api/latency_measurement.rb → latency_measurement.rb} +1 -2
- data/examples/{v3api/local_lat.rb → local_lat.rb} +1 -1
- data/examples/{v3api/local_lat_poll.rb → local_lat_poll.rb} +4 -4
- data/examples/{v3api/local_throughput.rb → local_throughput.rb} +1 -1
- data/examples/{v3api/pub.rb → pub.rb} +1 -1
- data/examples/{v2api/publish_subscribe.rb → publish_subscribe.rb} +2 -2
- data/examples/{v2api/remote_lat.rb → remote_lat.rb} +1 -1
- data/examples/{v3api/remote_throughput.rb → remote_throughput.rb} +4 -3
- data/examples/repreq_over_curve.rb +60 -0
- data/examples/{v2api/reqrep_poll.rb → reqrep_poll.rb} +3 -4
- data/examples/{v2api/request_response.rb → request_response.rb} +1 -2
- data/examples/{v3api/sub.rb → sub.rb} +1 -2
- data/examples/{v3api/throughput_measurement.rb → throughput_measurement.rb} +1 -1
- data/examples/{v3api/xreqxrep_poll.rb → xreqxrep_poll.rb} +6 -7
- data/ffi-rzmq.gemspec +4 -4
- data/lib/ffi-rzmq.rb +2 -3
- data/lib/ffi-rzmq/context.rb +25 -53
- data/lib/ffi-rzmq/device.rb +8 -4
- data/lib/ffi-rzmq/exceptions.rb +3 -0
- data/lib/ffi-rzmq/message.rb +24 -30
- data/lib/ffi-rzmq/poll.rb +5 -16
- data/lib/ffi-rzmq/socket.rb +132 -282
- data/lib/ffi-rzmq/util.rb +28 -36
- data/lib/ffi-rzmq/version.rb +1 -1
- data/spec/context_spec.rb +18 -23
- data/spec/device_spec.rb +13 -12
- data/spec/message_spec.rb +13 -13
- data/spec/multipart_spec.rb +11 -11
- data/spec/nonblocking_recv_spec.rb +22 -22
- data/spec/poll_spec.rb +49 -49
- data/spec/pushpull_spec.rb +12 -11
- data/spec/reqrep_spec.rb +11 -11
- data/spec/socket_spec.rb +109 -196
- data/spec/spec_helper.rb +3 -11
- data/spec/util_spec.rb +29 -0
- metadata +80 -104
- data/examples/v2api/latency_measurement.rb +0 -139
- data/examples/v2api/local_lat.rb +0 -58
- data/examples/v2api/local_lat_poll.rb +0 -66
- data/examples/v2api/local_throughput.rb +0 -58
- data/examples/v2api/pub.rb +0 -46
- data/examples/v2api/remote_throughput.rb +0 -39
- data/examples/v2api/sub.rb +0 -74
- data/examples/v2api/throughput_measurement.rb +0 -138
- data/examples/v2api/xreqxrep_poll.rb +0 -93
- data/examples/v3api/publish_subscribe.rb +0 -82
- data/examples/v3api/remote_lat.rb +0 -71
- data/examples/v3api/reqrep_poll.rb +0 -62
- data/examples/v3api/request_response.rb +0 -40
- data/lib/ffi-rzmq/constants.rb +0 -187
- data/lib/ffi-rzmq/libc.rb +0 -19
- data/lib/ffi-rzmq/libzmq.rb +0 -283
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 691dd239d1036375a2f06806953e89e7674d6c19
|
4
|
+
data.tar.gz: 74f1929b8be63e5d38b884e24a6bacab02fe90e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e78fb2755c2325b4de8fe3922d8c14b45a1171488ab26897c868f72e7b233b755ba1eb44bdacbd6ee4023d4228f9e57718bf86a0cf1cf427d3fb04b480d8876d
|
7
|
+
data.tar.gz: 3bc7c5bfb8d9212959a41fb8e7a00d3f73873fe5e8d68abded9f20aa182d4b6cd4d74a7d6d7e14030e5d66e5ef191cf22f1614cdffc217cc523df1cc17f91a66
|
data/.travis.yml
CHANGED
data/AUTHORS.txt
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,48 @@
|
|
1
|
+
== 2.0.4
|
2
|
+
* Screwed up the release managment. Had wrong version in version.rb. Fixed.
|
3
|
+
|
4
|
+
== 2.0.3
|
5
|
+
* Updated specs to use RSpec 3.x syntax. Never again... if they change it
|
6
|
+
then I'm dumping rspec.
|
7
|
+
|
8
|
+
* Now loading version.rb during startup so that ZMQ::VERSION returns a string.
|
9
|
+
|
10
|
+
* Modified README to point most people to the Ruby gem that wraps the CZMQ
|
11
|
+
library. It's a much higher-level library that makes writing zeromq apps
|
12
|
+
very easy. This gem is for writing low-level code which most people don't
|
13
|
+
want or need to do. This gem is going into maintenance mode only.
|
14
|
+
|
15
|
+
|
16
|
+
== 2.0.2
|
17
|
+
|
18
|
+
* Updated README to make it clearer which versions of libzmq are supported.
|
19
|
+
|
20
|
+
* Updated README to use a newer example.
|
21
|
+
|
22
|
+
== 2.0.1 / 20140122
|
23
|
+
* Fix setsockopt with string parameters for options that have very strict
|
24
|
+
requirements (like CURVE_SECRETKEY) (37aed3c)
|
25
|
+
|
26
|
+
* Provide a wrapper for zmq_curve_keypair for ZeroMQ4
|
27
|
+
|
28
|
+
== 2.0.0 / 20140108
|
29
|
+
* Split out all of the FFI code to its own gem so other projects can use
|
30
|
+
it without the effort of duplication.
|
31
|
+
|
32
|
+
* Support libzmq 4 API and its new security API . Thanks to Devin
|
33
|
+
Christensen (devin-c) and Jason Roelofs (jasonroelofs) for related
|
34
|
+
patches.
|
35
|
+
|
36
|
+
* Minor documentation fixes. Thanks to Michael Zaccari (mzaccari) for
|
37
|
+
the fix.
|
38
|
+
|
39
|
+
* Improved the readability of any FFI code (now moved to ffi-rzmq-core
|
40
|
+
project). Thanks to Stephen von Takach (stakach) for the patch.
|
41
|
+
|
42
|
+
* Updated AUTHORS.txt
|
43
|
+
|
44
|
+
|
45
|
+
|
1
46
|
== 1.0.3 / 20131003
|
2
47
|
* Fixes for issues #96 and #97. Thanks to Paul Chechetin (paulche) for
|
3
48
|
the issues and patches.
|
data/README.rdoc
CHANGED
@@ -2,6 +2,22 @@ ffi-rzmq
|
|
2
2
|
by Chuck Remes
|
3
3
|
http://www.zeromq.org/bindings:ruby-ffi
|
4
4
|
|
5
|
+
== FUTURE SUPPORT
|
6
|
+
|
7
|
+
Most people writing Zeromq applications in Ruby should be using the rbczmq
|
8
|
+
project. It wraps the CZMQ binding which is a much higher-level library
|
9
|
+
for writing Zeromq code. Find the Ruby gem here:
|
10
|
+
|
11
|
+
http://github.com/methodmissing/rbczmq
|
12
|
+
|
13
|
+
Few projects need to write the low-level zeromq code that this gem allows.
|
14
|
+
With the release of ffi-rzmq 2.0.3, this library is going into permanent
|
15
|
+
maintenance mode. As new versions of libzmq are released, interested parties
|
16
|
+
should send pull requests to this project or its related project
|
17
|
+
ffi-rzmq-core to support new features.
|
18
|
+
|
19
|
+
The original README text follows...
|
20
|
+
|
5
21
|
== DESCRIPTION:
|
6
22
|
|
7
23
|
This gem wraps the ZeroMQ networking library using the ruby FFI (foreign
|
@@ -9,11 +25,18 @@ function interface). It's a pure ruby wrapper so this gem can be loaded
|
|
9
25
|
and run by any ruby runtime that supports FFI. That's all of them:
|
10
26
|
MRI 1.9.x, Rubinius and JRuby.
|
11
27
|
|
12
|
-
|
28
|
+
The Ruby API provided by this gem is *NOT* very Ruby-like. It very closely
|
29
|
+
tracks the libzmq C API. However, the contributors to this project have
|
30
|
+
done all of the hard work to wrap up all of libzmq and make it accessible
|
31
|
+
from Ruby. If you want it to be more Ruby-like (e.g. raise Exceptions instead
|
32
|
+
of returning integer codes) then *wrap this library* with your own and release
|
33
|
+
it as a gem. We will all be grateful!
|
34
|
+
|
35
|
+
This single gem supports 0mq 3.2.x and 4.x APIs. The 0mq project started
|
13
36
|
making backward-incompatible changes to the API with the 3.1.x release.
|
14
37
|
The gem auto-configures itself to expose the API conforming to the loaded
|
15
|
-
C library. 0mq API 3.0 is *not* supported;
|
16
|
-
abandon it.
|
38
|
+
C library. 0mq 2.x is no longer supported. 0mq API 3.0 is *not* supported;
|
39
|
+
the 0mq community voted to abandon it.
|
17
40
|
|
18
41
|
The impetus behind this library was to provide support for ZeroMQ in
|
19
42
|
JRuby which has native threads. Unlike MRI, which has a GIL, JRuby and
|
@@ -36,7 +59,7 @@ than using a C extension.
|
|
36
59
|
== FEATURES/PROBLEMS:
|
37
60
|
|
38
61
|
This gem needs more tests. This gem has been battle tested by myself
|
39
|
-
and others for
|
62
|
+
and others for years, so I am fairly confident that it is solid.
|
40
63
|
However, it is inevitable that there will be bugs, so please open
|
41
64
|
issues for them here or fork this project, fix them, and send me a pull
|
42
65
|
request.
|
@@ -56,62 +79,71 @@ All features are implemented.
|
|
56
79
|
|
57
80
|
== SYNOPSIS:
|
58
81
|
|
59
|
-
0mq API
|
82
|
+
0mq API v3.2-4 client code:
|
60
83
|
|
61
84
|
require 'rubygems'
|
62
85
|
require 'ffi-rzmq'
|
63
86
|
|
64
87
|
if ARGV.length < 3
|
65
|
-
puts "usage: local_lat <connect-to> <message-size> <roundtrip-count>"
|
88
|
+
puts "usage: ruby local_lat.rb <connect-to> <message-size> <roundtrip-count>"
|
66
89
|
exit
|
67
90
|
end
|
68
|
-
|
91
|
+
|
69
92
|
bind_to = ARGV[0]
|
70
93
|
message_size = ARGV[1].to_i
|
71
94
|
roundtrip_count = ARGV[2].to_i
|
72
95
|
|
73
96
|
ctx = ZMQ::Context.new
|
74
|
-
s
|
75
|
-
rc
|
76
|
-
rc
|
97
|
+
s = ctx.socket ZMQ::REP
|
98
|
+
rc = s.setsockopt(ZMQ::SNDHWM, 100)
|
99
|
+
rc = s.setsockopt(ZMQ::RCVHWM, 100)
|
100
|
+
rc = s.bind(bind_to)
|
77
101
|
|
78
|
-
msg = ""
|
79
102
|
roundtrip_count.times do
|
80
|
-
|
103
|
+
msg = ""
|
104
|
+
rc = s.recv_string msg
|
81
105
|
raise "Message size doesn't match, expected [#{message_size}] but received [#{msg.size}]" if message_size != msg.size
|
82
|
-
rc
|
106
|
+
rc = s.send_string msg, 0
|
83
107
|
end
|
84
108
|
|
85
|
-
|
86
|
-
0mq API v2 server code:
|
109
|
+
0mq API v3.2-4 server code:
|
87
110
|
|
88
111
|
require 'rubygems'
|
89
112
|
require 'ffi-rzmq'
|
90
113
|
|
91
114
|
if ARGV.length < 3
|
92
|
-
puts "usage: remote_lat <connect-to> <message-size> <roundtrip-count>"
|
115
|
+
puts "usage: ruby remote_lat.rb <connect-to> <message-size> <roundtrip-count>"
|
93
116
|
exit
|
94
117
|
end
|
95
|
-
|
118
|
+
|
119
|
+
def assert(rc)
|
120
|
+
raise "Last API call failed at #{caller(1)}" unless rc >= 0
|
121
|
+
end
|
122
|
+
|
96
123
|
connect_to = ARGV[0]
|
97
124
|
message_size = ARGV[1].to_i
|
98
125
|
roundtrip_count = ARGV[2].to_i
|
99
126
|
|
100
127
|
ctx = ZMQ::Context.new
|
101
|
-
s
|
102
|
-
rc
|
128
|
+
s = ctx.socket ZMQ::REQ
|
129
|
+
rc = s.connect(connect_to)
|
103
130
|
|
104
131
|
msg = "#{ '3' * message_size }"
|
105
132
|
|
106
|
-
|
133
|
+
time_start = Time.now
|
107
134
|
|
108
|
-
msg = ""
|
109
135
|
roundtrip_count.times do
|
110
|
-
|
111
|
-
|
136
|
+
assert(s.send_string(msg, 0))
|
137
|
+
|
138
|
+
msg = ''
|
139
|
+
assert(s.recv_string(msg, 0))
|
140
|
+
|
112
141
|
raise "Message size doesn't match, expected [#{message_size}] but received [#{msg.size}]" if message_size != msg.size
|
113
142
|
end
|
114
143
|
|
144
|
+
time_end = Time.now
|
145
|
+
puts "Time #{( time_end - time_start )}"
|
146
|
+
|
115
147
|
== Better Examples
|
116
148
|
|
117
149
|
I highly recommend visiting the Learn Ruby 0mq project for a bunch of good code examples.
|
@@ -122,17 +154,15 @@ I highly recommend visiting the Learn Ruby 0mq project for a bunch of good code
|
|
122
154
|
|
123
155
|
== REQUIREMENTS:
|
124
156
|
|
125
|
-
* 0mq
|
157
|
+
* 0mq 3.2.x, 4.x or later; 2.x, 3.0.x and 3.1.x are no longer supported
|
126
158
|
|
127
159
|
The ZeroMQ library must be installed on your system in a well-known location
|
128
160
|
like /usr/local/lib. This is the default for new ZeroMQ installs.
|
129
161
|
|
130
162
|
If you have installed ZeroMQ using brew, you need to `brew link zeromq` before installing this gem.
|
131
163
|
|
132
|
-
Future releases may include the library as a C extension built at
|
133
|
-
time of installation.
|
134
|
-
|
135
164
|
* ffi (>= 1.0.0)
|
165
|
+
* ffi-rzmq-core
|
136
166
|
|
137
167
|
This is a requirement for MRI and Rubinius. JRuby has FFI support built
|
138
168
|
in as a standard component. Do *not* run this gem under MRI with an old 'ffi' gem.
|
@@ -141,7 +171,7 @@ It will crash randomly and you will be sad.
|
|
141
171
|
|
142
172
|
== INSTALL:
|
143
173
|
|
144
|
-
Make sure the ZeroMQ library is already installed on your system.
|
174
|
+
Make sure the ZeroMQ library is already installed on your system. We recommend 'brew' or 'macports' to get it.
|
145
175
|
|
146
176
|
% gem install ffi-rzmq # should grab the latest release
|
147
177
|
|
data/Rakefile
CHANGED
@@ -4,3 +4,18 @@ require 'rspec/core/rake_task'
|
|
4
4
|
RSpec::Core::RakeTask.new
|
5
5
|
|
6
6
|
task :default => :spec
|
7
|
+
|
8
|
+
task :console do
|
9
|
+
require 'irb'
|
10
|
+
require 'irb/completion'
|
11
|
+
require 'ffi-rzmq'
|
12
|
+
ARGV.clear
|
13
|
+
IRB.start
|
14
|
+
end
|
15
|
+
|
16
|
+
task :pryconsole do
|
17
|
+
require 'pry'
|
18
|
+
require 'ffi-rzmq'
|
19
|
+
ARGV.clear
|
20
|
+
Pry.start
|
21
|
+
end
|
data/examples/README.rdoc
CHANGED
@@ -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
|
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__), '..', '
|
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__), '..', '
|
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__), '..', '
|
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::
|
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::
|
53
|
-
assert(socket.sendmsg(ZMQ::Message.new(received_message), ZMQ::
|
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,4 +1,4 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '
|
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::
|
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__), '..', '
|
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__), '..', '
|
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
|
-
#
|
30
|
+
# give the downstream SUB socket a chance to register its
|
31
31
|
# subscription filters with this PUB socket
|
32
|
-
|
32
|
+
puts "Hit any key to start publishing"
|
33
|
+
STDIN.gets
|
33
34
|
|
34
35
|
contents = "#{'0'*message_size}"
|
35
36
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'ffi-rzmq')
|
2
|
+
|
3
|
+
# This example shows the basics of a CURVE-secured REP/REQ setup between
|
4
|
+
# a Server and Client. This is the minimal required setup for authenticating
|
5
|
+
# a connection between a Client and a Server. For validating the Client's authentication
|
6
|
+
# once the initial connection has succeeded, you'll need a ZAP handler on the Server.
|
7
|
+
|
8
|
+
# Build the Server's keys
|
9
|
+
server_public_key, server_private_key = ZMQ::Util.curve_keypair
|
10
|
+
|
11
|
+
# Build the Client's keys
|
12
|
+
client_public_key, client_private_key = ZMQ::Util.curve_keypair
|
13
|
+
|
14
|
+
context = ZMQ::Context.new
|
15
|
+
bind_point = "tcp://127.0.0.1:4455"
|
16
|
+
|
17
|
+
##
|
18
|
+
# Configure the Server
|
19
|
+
##
|
20
|
+
server = context.socket ZMQ::REP
|
21
|
+
|
22
|
+
server.setsockopt(ZMQ::CURVE_SERVER, 1)
|
23
|
+
server.setsockopt(ZMQ::CURVE_SECRETKEY, server_private_key)
|
24
|
+
|
25
|
+
server.bind(bind_point)
|
26
|
+
|
27
|
+
##
|
28
|
+
# Configure the Client to talk to the Server
|
29
|
+
##
|
30
|
+
client = context.socket ZMQ::REQ
|
31
|
+
|
32
|
+
client.setsockopt(ZMQ::CURVE_SERVERKEY, server_public_key)
|
33
|
+
client.setsockopt(ZMQ::CURVE_PUBLICKEY, client_public_key)
|
34
|
+
client.setsockopt(ZMQ::CURVE_SECRETKEY, client_private_key)
|
35
|
+
|
36
|
+
client.connect(bind_point)
|
37
|
+
|
38
|
+
##
|
39
|
+
# Show that communication still works
|
40
|
+
##
|
41
|
+
|
42
|
+
client_message = "Hello Server!"
|
43
|
+
server_response = "Hello Client!"
|
44
|
+
|
45
|
+
puts "Client sending: #{client_message}"
|
46
|
+
client.send_string client_message
|
47
|
+
|
48
|
+
server.recv_string(server_message = '')
|
49
|
+
puts "Server received: #{server_message}, replying with #{server_response}"
|
50
|
+
|
51
|
+
server.send_string(server_response)
|
52
|
+
|
53
|
+
client.recv_string(response = '')
|
54
|
+
puts "Client has received: #{response}"
|
55
|
+
|
56
|
+
puts "Finished"
|
57
|
+
|
58
|
+
client.close
|
59
|
+
server.close
|
60
|
+
context.terminate
|