eventmachine 1.0.3-x86-mingw32 → 1.2.0.dev.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +84 -1
- data/README.md +6 -7
- data/ext/binder.cpp +10 -10
- data/ext/binder.h +5 -5
- data/ext/cmain.cpp +173 -61
- data/ext/ed.cpp +262 -127
- data/ext/ed.h +50 -30
- data/ext/em.cpp +491 -445
- data/ext/em.h +101 -36
- data/ext/eventmachine.h +67 -51
- data/ext/extconf.rb +124 -31
- data/ext/fastfilereader/extconf.rb +9 -2
- data/ext/fastfilereader/mapper.cpp +3 -1
- data/ext/fastfilereader/rubymain.cpp +7 -7
- data/ext/kb.cpp +1 -1
- data/ext/pipe.cpp +11 -4
- data/ext/project.h +26 -6
- data/ext/rubymain.cpp +408 -201
- data/ext/ssl.cpp +167 -20
- data/ext/ssl.h +11 -2
- data/java/src/com/rubyeventmachine/EmReactor.java +16 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +2 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +6 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +55 -10
- data/lib/1.9/fastfilereaderext.so +0 -0
- data/lib/1.9/rubyeventmachine.so +0 -0
- data/lib/2.0/fastfilereaderext.so +0 -0
- data/lib/2.0/rubyeventmachine.so +0 -0
- data/lib/2.1/fastfilereaderext.so +0 -0
- data/lib/2.1/rubyeventmachine.so +0 -0
- data/lib/2.2/fastfilereaderext.so +0 -0
- data/lib/2.2/rubyeventmachine.so +0 -0
- data/lib/2.3/fastfilereaderext.so +0 -0
- data/lib/2.3/rubyeventmachine.so +0 -0
- data/lib/em/buftok.rb +34 -85
- data/lib/em/channel.rb +5 -0
- data/lib/em/completion.rb +2 -2
- data/lib/em/connection.rb +62 -4
- data/lib/em/iterator.rb +30 -48
- data/lib/em/pool.rb +1 -1
- data/lib/em/protocols/httpclient.rb +31 -11
- data/lib/em/protocols/line_and_text.rb +4 -4
- data/lib/em/protocols/linetext2.rb +44 -39
- data/lib/em/protocols/smtpclient.rb +60 -31
- data/lib/em/protocols/smtpserver.rb +32 -9
- data/lib/em/pure_ruby.rb +8 -3
- data/lib/em/queue.rb +16 -7
- data/lib/em/resolver.rb +64 -24
- data/lib/em/threaded_resource.rb +2 -2
- data/lib/em/tick_loop.rb +19 -19
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +96 -49
- data/lib/jeventmachine.rb +17 -0
- data/rakelib/package.rake +31 -4
- data/tests/dhparam.pem +13 -0
- data/tests/em_test_helper.rb +87 -0
- data/tests/test_attach.rb +25 -0
- data/tests/test_basic.rb +27 -38
- data/tests/test_channel.rb +14 -1
- data/tests/test_completion.rb +1 -0
- data/tests/test_connection_count.rb +22 -1
- data/tests/test_connection_write.rb +35 -0
- data/tests/test_defer.rb +17 -0
- data/tests/test_epoll.rb +26 -14
- data/tests/test_file_watch.rb +1 -0
- data/tests/test_fork.rb +75 -0
- data/tests/test_httpclient.rb +43 -0
- data/tests/test_idle_connection.rb +6 -4
- data/tests/test_ipv4.rb +125 -0
- data/tests/test_ipv6.rb +131 -0
- data/tests/test_iterator.rb +115 -0
- data/tests/test_kb.rb +19 -25
- data/tests/test_ltp2.rb +20 -0
- data/tests/test_many_fds.rb +22 -0
- data/tests/test_pause.rb +29 -0
- data/tests/test_pool.rb +2 -0
- data/tests/test_process_watch.rb +2 -0
- data/tests/test_processes.rb +7 -7
- data/tests/test_queue.rb +14 -0
- data/tests/test_resolver.rb +56 -7
- data/tests/test_set_sock_opt.rb +2 -0
- data/tests/test_smtpclient.rb +20 -0
- data/tests/test_ssl_args.rb +2 -2
- data/tests/test_ssl_dhparam.rb +83 -0
- data/tests/test_ssl_ecdh_curve.rb +79 -0
- data/tests/test_ssl_extensions.rb +49 -0
- data/tests/test_ssl_methods.rb +22 -5
- data/tests/test_ssl_protocols.rb +246 -0
- data/tests/test_ssl_verify.rb +103 -59
- data/tests/test_system.rb +4 -0
- data/tests/test_threaded_resource.rb +8 -0
- data/tests/test_unbind_reason.rb +5 -1
- metadata +173 -107
- data/.gitignore +0 -21
- data/.travis.yml +0 -12
- data/.yardopts +0 -7
- data/Gemfile +0 -2
- data/Rakefile +0 -20
- data/eventmachine.gemspec +0 -36
- data/rakelib/cpp.rake_example +0 -77
data/tests/test_defer.rb
CHANGED
@@ -15,4 +15,21 @@ class TestDefer < Test::Unit::TestCase
|
|
15
15
|
assert_equal( n, n_times )
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_errbacks
|
19
|
+
iterations = 20
|
20
|
+
callback_parameter = rand(100)
|
21
|
+
callback_parameters = []
|
22
|
+
callback_op = proc { callback_parameter }
|
23
|
+
callback = proc { |result| callback_parameters << result }
|
24
|
+
errback_parameter = Exception.new
|
25
|
+
errback_parameters = []
|
26
|
+
errback_op = proc { raise errback_parameter }
|
27
|
+
errback = proc { |error| errback_parameters << error }
|
28
|
+
EventMachine.run do
|
29
|
+
(1..iterations).each { |index| EventMachine.defer(index.even? ? callback_op : errback_op, callback, errback) }
|
30
|
+
EventMachine.add_periodic_timer(0.1) { EventMachine.stop if EventMachine.defers_finished? }
|
31
|
+
end
|
32
|
+
assert_equal(callback_parameters.select { |parameter| parameter == callback_parameter }.length, iterations * 0.5)
|
33
|
+
assert_equal(errback_parameters.select{ |parameter| parameter == errback_parameter }.length, iterations * 0.5)
|
34
|
+
end
|
18
35
|
end
|
data/tests/test_epoll.rb
CHANGED
@@ -25,19 +25,16 @@ class TestEpoll < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
a = EM.set_descriptor_table_size( 1024 )
|
39
|
-
assert( a == 1024 )
|
40
|
-
end
|
28
|
+
# We can set the rlimit/nofile of a process but we can only set it
|
29
|
+
# higher if we're running as root.
|
30
|
+
# On most systems, the default value is 1024.
|
31
|
+
def test_rlimit
|
32
|
+
omit_if(windows? || jruby?)
|
33
|
+
unless EM.set_descriptor_table_size >= 1024
|
34
|
+
a = EM.set_descriptor_table_size
|
35
|
+
assert( a <= 1024 )
|
36
|
+
a = EM.set_descriptor_table_size( 1024 )
|
37
|
+
assert( a == 1024 )
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
@@ -97,7 +94,7 @@ class TestEpoll < Test::Unit::TestCase
|
|
97
94
|
assert_equal( "abcdefghij", $out )
|
98
95
|
end
|
99
96
|
|
100
|
-
# XXX this test fails randomly
|
97
|
+
# XXX this test fails randomly...
|
101
98
|
def _test_unix_domain
|
102
99
|
fn = "/tmp/xxx.chain"
|
103
100
|
EM.epoll
|
@@ -126,5 +123,20 @@ class TestEpoll < Test::Unit::TestCase
|
|
126
123
|
File.unlink(fn) if File.exist?(fn)
|
127
124
|
end
|
128
125
|
|
126
|
+
def test_attach_detach
|
127
|
+
EM.epoll
|
128
|
+
EM.run {
|
129
|
+
EM.add_timer(0.01) { EM.stop }
|
130
|
+
|
131
|
+
r, _ = IO.pipe
|
132
|
+
|
133
|
+
# This tests a regression where detach in the same tick as attach crashes EM
|
134
|
+
EM.watch(r) do |connection|
|
135
|
+
connection.detach
|
136
|
+
end
|
137
|
+
}
|
138
|
+
|
139
|
+
assert true
|
140
|
+
end
|
129
141
|
end
|
130
142
|
|
data/tests/test_file_watch.rb
CHANGED
data/tests/test_fork.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
|
3
|
+
class TestFork < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_fork_safe
|
6
|
+
omit_if(jruby?)
|
7
|
+
omit_if(windows?)
|
8
|
+
|
9
|
+
fork_pid = nil
|
10
|
+
read, write = IO.pipe
|
11
|
+
EM.run do
|
12
|
+
fork_pid = fork do
|
13
|
+
write.puts "forked"
|
14
|
+
EM.run do
|
15
|
+
EM.next_tick do
|
16
|
+
write.puts "EM ran"
|
17
|
+
EM.stop
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
EM.stop
|
22
|
+
end
|
23
|
+
|
24
|
+
sleep 0.1
|
25
|
+
begin
|
26
|
+
Timeout::timeout 1 do
|
27
|
+
assert_equal "forked\n", read.readline
|
28
|
+
assert_equal "EM ran\n", read.readline
|
29
|
+
end
|
30
|
+
rescue Timeout::Error
|
31
|
+
Process.kill 'TERM', fork_pid
|
32
|
+
flunk "Timeout waiting for next_tick in new fork reactor"
|
33
|
+
end
|
34
|
+
ensure
|
35
|
+
read.close rescue nil
|
36
|
+
write.close rescue nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_fork_reactor
|
40
|
+
omit_if(jruby?)
|
41
|
+
omit_if(windows?)
|
42
|
+
|
43
|
+
fork_pid = nil
|
44
|
+
read, write = IO.pipe
|
45
|
+
EM.run do
|
46
|
+
EM.defer do
|
47
|
+
write.puts Process.pid
|
48
|
+
EM.defer do
|
49
|
+
EM.stop
|
50
|
+
end
|
51
|
+
end
|
52
|
+
fork_pid = EM.fork_reactor do
|
53
|
+
EM.defer do
|
54
|
+
write.puts Process.pid
|
55
|
+
EM.stop
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
sleep 0.1
|
61
|
+
begin
|
62
|
+
Timeout::timeout 1 do
|
63
|
+
assert_equal Process.pid.to_s, read.readline.chomp
|
64
|
+
assert_equal fork_pid.to_s, read.readline.chomp
|
65
|
+
end
|
66
|
+
rescue Timeout::Error
|
67
|
+
Process.kill 'TERM', fork_pid
|
68
|
+
flunk "Timeout waiting for deferred block in fork_reactor"
|
69
|
+
end
|
70
|
+
ensure
|
71
|
+
read.close rescue nil
|
72
|
+
write.close rescue nil
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/tests/test_httpclient.rb
CHANGED
@@ -187,4 +187,47 @@ class TestHttpClient < Test::Unit::TestCase
|
|
187
187
|
assert ok
|
188
188
|
end
|
189
189
|
|
190
|
+
#-----------------------------------------
|
191
|
+
|
192
|
+
# Test a server that returns chunked encoding
|
193
|
+
#
|
194
|
+
class ChunkedEncodingContent < EventMachine::Connection
|
195
|
+
def initialize *args
|
196
|
+
super
|
197
|
+
end
|
198
|
+
def receive_data data
|
199
|
+
send_data ["HTTP/1.1 200 OK",
|
200
|
+
"Server: nginx/0.7.67",
|
201
|
+
"Date: Sat, 23 Oct 2010 16:41:32 GMT",
|
202
|
+
"Content-Type: application/json",
|
203
|
+
"Transfer-Encoding: chunked",
|
204
|
+
"Connection: keep-alive",
|
205
|
+
"",
|
206
|
+
"1800",
|
207
|
+
"chunk1" * 1024,
|
208
|
+
"5a",
|
209
|
+
"chunk2" * 15,
|
210
|
+
"0",
|
211
|
+
""].join("\r\n")
|
212
|
+
close_connection_after_writing
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_http_chunked_encoding_content
|
217
|
+
ok = false
|
218
|
+
EventMachine.run {
|
219
|
+
EventMachine.start_server "127.0.0.1", 9701, ChunkedEncodingContent
|
220
|
+
c = EventMachine::Protocols::HttpClient.send :request, :host => "127.0.0.1", :port => 9701
|
221
|
+
c.callback {|result|
|
222
|
+
if result[:content] == "chunk1" * 1024 + "chunk2" * 15
|
223
|
+
ok = true
|
224
|
+
end
|
225
|
+
EventMachine.stop
|
226
|
+
}
|
227
|
+
}
|
228
|
+
assert ok
|
229
|
+
end
|
230
|
+
|
190
231
|
end
|
232
|
+
|
233
|
+
|
@@ -9,15 +9,17 @@ class TestIdleConnection < Test::Unit::TestCase
|
|
9
9
|
$idle_time = conn.get_idle_time
|
10
10
|
conn.send_data "GET / HTTP/1.0\r\n\r\n"
|
11
11
|
EM.next_tick{
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
EM.next_tick{
|
13
|
+
$idle_time_after_send = conn.get_idle_time
|
14
|
+
conn.close_connection
|
15
|
+
EM.stop
|
16
|
+
}
|
15
17
|
}
|
16
18
|
}
|
17
19
|
}
|
18
20
|
|
19
21
|
assert_in_delta 3, $idle_time, 0.2
|
20
|
-
|
22
|
+
assert_in_delta 0, $idle_time_after_send, 0.1
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
data/tests/test_ipv4.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
class TestIPv4 < Test::Unit::TestCase
|
5
|
+
|
6
|
+
if Test::Unit::TestCase.public_ipv4?
|
7
|
+
|
8
|
+
# Tries to connect to www.google.com port 80 via TCP.
|
9
|
+
# Timeout in 2 seconds.
|
10
|
+
def test_ipv4_tcp_client
|
11
|
+
conn = nil
|
12
|
+
setup_timeout(2)
|
13
|
+
|
14
|
+
EM.run do
|
15
|
+
conn = EM::connect("www.google.com", 80) do |c|
|
16
|
+
def c.connected
|
17
|
+
@connected
|
18
|
+
end
|
19
|
+
|
20
|
+
def c.connection_completed
|
21
|
+
@connected = true
|
22
|
+
EM.stop
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
assert conn.connected
|
28
|
+
end
|
29
|
+
|
30
|
+
# Runs a TCP server in the local IPv4 address, connects to it and sends a specific data.
|
31
|
+
# Timeout in 2 seconds.
|
32
|
+
def test_ipv4_tcp_local_server
|
33
|
+
@@received_data = nil
|
34
|
+
@local_port = next_port
|
35
|
+
setup_timeout(2)
|
36
|
+
|
37
|
+
EM.run do
|
38
|
+
EM::start_server(@@public_ipv4, @local_port) do |s|
|
39
|
+
def s.receive_data data
|
40
|
+
@@received_data = data
|
41
|
+
EM.stop
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
EM::connect(@@public_ipv4, @local_port) do |c|
|
46
|
+
c.send_data "ipv4/tcp"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_equal "ipv4/tcp", @@received_data
|
51
|
+
end
|
52
|
+
|
53
|
+
# Runs a UDP server in the local IPv4 address, connects to it and sends a specific data.
|
54
|
+
# Timeout in 2 seconds.
|
55
|
+
def test_ipv4_udp_local_server
|
56
|
+
@@received_data = nil
|
57
|
+
@local_port = next_port
|
58
|
+
setup_timeout(2)
|
59
|
+
|
60
|
+
EM.run do
|
61
|
+
EM::open_datagram_socket(@@public_ipv4, @local_port) do |s|
|
62
|
+
def s.receive_data data
|
63
|
+
@@received_data = data
|
64
|
+
EM.stop
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
EM::open_datagram_socket(@@public_ipv4, next_port) do |c|
|
69
|
+
c.send_datagram "ipv4/udp", @@public_ipv4, @local_port
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
assert_equal "ipv4/udp", @@received_data
|
74
|
+
end
|
75
|
+
|
76
|
+
# Try to connect via TCP to an invalid IPv4. EM.connect should raise
|
77
|
+
# EM::ConnectionError.
|
78
|
+
def test_tcp_connect_to_invalid_ipv4
|
79
|
+
invalid_ipv4 = "9.9:9"
|
80
|
+
|
81
|
+
EM.run do
|
82
|
+
begin
|
83
|
+
error = nil
|
84
|
+
EM.connect(invalid_ipv4, 1234)
|
85
|
+
rescue => e
|
86
|
+
error = e
|
87
|
+
ensure
|
88
|
+
EM.stop
|
89
|
+
assert_equal EM::ConnectionError, (error && error.class)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Try to send a UDP datagram to an invalid IPv4. EM.send_datagram should raise
|
95
|
+
# EM::ConnectionError.
|
96
|
+
def test_udp_send_datagram_to_invalid_ipv4
|
97
|
+
invalid_ipv4 = "9.9:9"
|
98
|
+
|
99
|
+
EM.run do
|
100
|
+
begin
|
101
|
+
error = nil
|
102
|
+
EM.open_datagram_socket(@@public_ipv4, next_port) do |c|
|
103
|
+
c.send_datagram "hello", invalid_ipv4, 1234
|
104
|
+
end
|
105
|
+
rescue => e
|
106
|
+
error = e
|
107
|
+
ensure
|
108
|
+
EM.stop
|
109
|
+
assert_equal EM::ConnectionError, (error && error.class)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
else
|
116
|
+
warn "no IPv4 in this host, skipping tests in #{__FILE__}"
|
117
|
+
|
118
|
+
# Because some rubies will complain if a TestCase class has no tests
|
119
|
+
def test_ipv4_unavailable
|
120
|
+
assert true
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
data/tests/test_ipv6.rb
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
|
3
|
+
class TestIPv6 < Test::Unit::TestCase
|
4
|
+
|
5
|
+
if Test::Unit::TestCase.public_ipv6?
|
6
|
+
|
7
|
+
# Tries to connect to ipv6.google.com (2607:f8b0:4010:800::1006) port 80 via TCP.
|
8
|
+
# Timeout in 6 seconds.
|
9
|
+
def test_ipv6_tcp_client_with_ipv6_google_com
|
10
|
+
conn = nil
|
11
|
+
setup_timeout(6)
|
12
|
+
|
13
|
+
EM.run do
|
14
|
+
conn = EM::connect("2607:f8b0:4010:800::1006", 80) do |c|
|
15
|
+
def c.connected
|
16
|
+
@connected
|
17
|
+
end
|
18
|
+
|
19
|
+
def c.unbind(reason)
|
20
|
+
warn "unbind: #{reason.inspect}" if reason # XXX at least find out why it failed
|
21
|
+
end
|
22
|
+
|
23
|
+
def c.connection_completed
|
24
|
+
@connected = true
|
25
|
+
EM.stop
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
assert conn.connected
|
31
|
+
end
|
32
|
+
|
33
|
+
# Runs a TCP server in the local IPv6 address, connects to it and sends a specific data.
|
34
|
+
# Timeout in 2 seconds.
|
35
|
+
def test_ipv6_tcp_local_server
|
36
|
+
@@received_data = nil
|
37
|
+
@local_port = next_port
|
38
|
+
setup_timeout(2)
|
39
|
+
|
40
|
+
EM.run do
|
41
|
+
EM.start_server(@@public_ipv6, @local_port) do |s|
|
42
|
+
def s.receive_data data
|
43
|
+
@@received_data = data
|
44
|
+
EM.stop
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
EM::connect(@@public_ipv6, @local_port) do |c|
|
49
|
+
def c.unbind(reason)
|
50
|
+
warn "unbind: #{reason.inspect}" if reason # XXX at least find out why it failed
|
51
|
+
end
|
52
|
+
c.send_data "ipv6/tcp"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
assert_equal "ipv6/tcp", @@received_data
|
57
|
+
end
|
58
|
+
|
59
|
+
# Runs a UDP server in the local IPv6 address, connects to it and sends a specific data.
|
60
|
+
# Timeout in 2 seconds.
|
61
|
+
def test_ipv6_udp_local_server
|
62
|
+
@@received_data = nil
|
63
|
+
@local_port = next_port
|
64
|
+
setup_timeout(2)
|
65
|
+
|
66
|
+
EM.run do
|
67
|
+
EM.open_datagram_socket(@@public_ipv6, @local_port) do |s|
|
68
|
+
def s.receive_data data
|
69
|
+
@@received_data = data
|
70
|
+
EM.stop
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
EM.open_datagram_socket(@@public_ipv6, next_port) do |c|
|
75
|
+
c.send_datagram "ipv6/udp", @@public_ipv6, @local_port
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
assert_equal "ipv6/udp", @@received_data
|
80
|
+
end
|
81
|
+
|
82
|
+
# Try to connect via TCP to an invalid IPv6. EM.connect should raise
|
83
|
+
# EM::ConnectionError.
|
84
|
+
def test_tcp_connect_to_invalid_ipv6
|
85
|
+
invalid_ipv6 = "1:A"
|
86
|
+
|
87
|
+
EM.run do
|
88
|
+
begin
|
89
|
+
error = nil
|
90
|
+
EM.connect(invalid_ipv6, 1234)
|
91
|
+
rescue => e
|
92
|
+
error = e
|
93
|
+
ensure
|
94
|
+
EM.stop
|
95
|
+
assert_equal EM::ConnectionError, (error && error.class)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Try to send a UDP datagram to an invalid IPv6. EM.send_datagram should raise
|
101
|
+
# EM::ConnectionError.
|
102
|
+
def test_udp_send_datagram_to_invalid_ipv6
|
103
|
+
invalid_ipv6 = "1:A"
|
104
|
+
|
105
|
+
EM.run do
|
106
|
+
begin
|
107
|
+
error = nil
|
108
|
+
EM.open_datagram_socket(@@public_ipv6, next_port) do |c|
|
109
|
+
c.send_datagram "hello", invalid_ipv6, 1234
|
110
|
+
end
|
111
|
+
rescue => e
|
112
|
+
error = e
|
113
|
+
ensure
|
114
|
+
EM.stop
|
115
|
+
assert_equal EM::ConnectionError, (error && error.class)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
else
|
122
|
+
warn "no IPv6 in this host, skipping tests in #{__FILE__}"
|
123
|
+
|
124
|
+
# Because some rubies will complain if a TestCase class has no tests.
|
125
|
+
def test_ipv6_unavailable
|
126
|
+
assert true
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|