eventmachine-with-ipv6 1.0.0.beta.4.ipv6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/.yardopts +7 -0
- data/FORK.md +47 -0
- data/GNU +281 -0
- data/Gemfile +3 -0
- data/LICENSE +60 -0
- data/README.md +109 -0
- data/Rakefile +20 -0
- data/docs/DocumentationGuidesIndex.md +27 -0
- data/docs/GettingStarted.md +521 -0
- data/docs/old/ChangeLog +211 -0
- data/docs/old/DEFERRABLES +246 -0
- data/docs/old/EPOLL +141 -0
- data/docs/old/INSTALL +13 -0
- data/docs/old/KEYBOARD +42 -0
- data/docs/old/LEGAL +25 -0
- data/docs/old/LIGHTWEIGHT_CONCURRENCY +130 -0
- data/docs/old/PURE_RUBY +75 -0
- data/docs/old/RELEASE_NOTES +94 -0
- data/docs/old/SMTP +4 -0
- data/docs/old/SPAWNED_PROCESSES +148 -0
- data/docs/old/TODO +8 -0
- data/eventmachine.gemspec +50 -0
- data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
- data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
- data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
- data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
- data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
- data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
- data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
- data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
- data/examples/old/ex_channel.rb +43 -0
- data/examples/old/ex_queue.rb +2 -0
- data/examples/old/ex_tick_loop_array.rb +15 -0
- data/examples/old/ex_tick_loop_counter.rb +32 -0
- data/examples/old/helper.rb +2 -0
- data/ext/binder.cpp +124 -0
- data/ext/binder.h +46 -0
- data/ext/cmain.cpp +858 -0
- data/ext/ed.cpp +1992 -0
- data/ext/ed.h +423 -0
- data/ext/em.cpp +2358 -0
- data/ext/em.h +245 -0
- data/ext/eventmachine.h +127 -0
- data/ext/extconf.rb +166 -0
- data/ext/fastfilereader/extconf.rb +94 -0
- data/ext/fastfilereader/mapper.cpp +214 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/ext/kb.cpp +79 -0
- data/ext/page.cpp +107 -0
- data/ext/page.h +51 -0
- data/ext/pipe.cpp +347 -0
- data/ext/project.h +155 -0
- data/ext/rubymain.cpp +1280 -0
- data/ext/ssl.cpp +468 -0
- data/ext/ssl.h +94 -0
- data/java/.classpath +8 -0
- data/java/.project +17 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +571 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +69 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -0
- data/lib/em/buftok.rb +110 -0
- data/lib/em/callback.rb +58 -0
- data/lib/em/channel.rb +64 -0
- data/lib/em/completion.rb +304 -0
- data/lib/em/connection.rb +728 -0
- data/lib/em/deferrable.rb +210 -0
- data/lib/em/deferrable/pool.rb +2 -0
- data/lib/em/file_watch.rb +73 -0
- data/lib/em/future.rb +61 -0
- data/lib/em/iterator.rb +270 -0
- data/lib/em/messages.rb +66 -0
- data/lib/em/pool.rb +151 -0
- data/lib/em/process_watch.rb +45 -0
- data/lib/em/processes.rb +123 -0
- data/lib/em/protocols.rb +36 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +279 -0
- data/lib/em/protocols/httpclient2.rb +600 -0
- data/lib/em/protocols/line_and_text.rb +125 -0
- data/lib/em/protocols/line_protocol.rb +29 -0
- data/lib/em/protocols/linetext2.rb +161 -0
- data/lib/em/protocols/memcache.rb +331 -0
- data/lib/em/protocols/object_protocol.rb +46 -0
- data/lib/em/protocols/postgres3.rb +246 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +365 -0
- data/lib/em/protocols/smtpserver.rb +640 -0
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/protocols/stomp.rb +202 -0
- data/lib/em/protocols/tcptest.rb +54 -0
- data/lib/em/pure_ruby.rb +1017 -0
- data/lib/em/queue.rb +71 -0
- data/lib/em/resolver.rb +195 -0
- data/lib/em/spawnable.rb +84 -0
- data/lib/em/streamer.rb +118 -0
- data/lib/em/threaded_resource.rb +90 -0
- data/lib/em/tick_loop.rb +85 -0
- data/lib/em/timers.rb +61 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1517 -0
- data/lib/jeventmachine.rb +279 -0
- data/rakelib/cpp.rake_example +77 -0
- data/rakelib/package.rake +98 -0
- data/rakelib/test.rake +8 -0
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/em_test_helper.rb +64 -0
- data/tests/test_attach.rb +126 -0
- data/tests/test_basic.rb +294 -0
- data/tests/test_channel.rb +62 -0
- data/tests/test_completion.rb +177 -0
- data/tests/test_connection_count.rb +33 -0
- data/tests/test_defer.rb +18 -0
- data/tests/test_deferrable.rb +35 -0
- data/tests/test_epoll.rb +134 -0
- data/tests/test_error_handler.rb +38 -0
- data/tests/test_exc.rb +28 -0
- data/tests/test_file_watch.rb +65 -0
- data/tests/test_futures.rb +170 -0
- data/tests/test_get_sock_opt.rb +37 -0
- data/tests/test_handler_check.rb +35 -0
- data/tests/test_hc.rb +155 -0
- data/tests/test_httpclient.rb +190 -0
- data/tests/test_httpclient2.rb +128 -0
- data/tests/test_inactivity_timeout.rb +54 -0
- data/tests/test_ipv4.rb +128 -0
- data/tests/test_ipv6.rb +135 -0
- data/tests/test_kb.rb +34 -0
- data/tests/test_ltp.rb +138 -0
- data/tests/test_ltp2.rb +288 -0
- data/tests/test_next_tick.rb +104 -0
- data/tests/test_object_protocol.rb +36 -0
- data/tests/test_pause.rb +78 -0
- data/tests/test_pending_connect_timeout.rb +52 -0
- data/tests/test_pool.rb +194 -0
- data/tests/test_process_watch.rb +48 -0
- data/tests/test_processes.rb +133 -0
- data/tests/test_proxy_connection.rb +168 -0
- data/tests/test_pure.rb +88 -0
- data/tests/test_queue.rb +50 -0
- data/tests/test_resolver.rb +55 -0
- data/tests/test_running.rb +14 -0
- data/tests/test_sasl.rb +47 -0
- data/tests/test_send_file.rb +217 -0
- data/tests/test_servers.rb +33 -0
- data/tests/test_set_sock_opt.rb +41 -0
- data/tests/test_shutdown_hooks.rb +23 -0
- data/tests/test_smtpclient.rb +55 -0
- data/tests/test_smtpserver.rb +57 -0
- data/tests/test_spawn.rb +293 -0
- data/tests/test_ssl_args.rb +78 -0
- data/tests/test_ssl_methods.rb +48 -0
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_threaded_resource.rb +53 -0
- data/tests/test_tick_loop.rb +59 -0
- data/tests/test_timers.rb +123 -0
- data/tests/test_ud.rb +8 -0
- data/tests/test_udp46.rb +54 -0
- data/tests/test_unbind_reason.rb +48 -0
- metadata +319 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
|
3
|
+
if EM.ssl?
|
4
|
+
class TestSslVerify < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
$dir = File.dirname(File.expand_path(__FILE__)) + '/'
|
7
|
+
$cert_from_file = File.read($dir+'client.crt')
|
8
|
+
end
|
9
|
+
|
10
|
+
module Client
|
11
|
+
def connection_completed
|
12
|
+
start_tls(:private_key_file => $dir+'client.key', :cert_chain_file => $dir+'client.crt')
|
13
|
+
end
|
14
|
+
|
15
|
+
def ssl_handshake_completed
|
16
|
+
$client_handshake_completed = true
|
17
|
+
close_connection
|
18
|
+
end
|
19
|
+
|
20
|
+
def unbind
|
21
|
+
EM.stop_event_loop
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module AcceptServer
|
26
|
+
def post_init
|
27
|
+
start_tls(:verify_peer => true)
|
28
|
+
end
|
29
|
+
|
30
|
+
def ssl_verify_peer(cert)
|
31
|
+
$cert_from_server = cert
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
def ssl_handshake_completed
|
36
|
+
$server_handshake_completed = true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module DenyServer
|
41
|
+
def post_init
|
42
|
+
start_tls(:verify_peer => true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def ssl_verify_peer(cert)
|
46
|
+
$cert_from_server = cert
|
47
|
+
# Do not accept the peer. This should now cause the connection to shut down without the SSL handshake being completed.
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
def ssl_handshake_completed
|
52
|
+
$server_handshake_completed = true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_accept_server
|
57
|
+
$client_handshake_completed, $server_handshake_completed = false, false
|
58
|
+
EM.run {
|
59
|
+
EM.start_server("127.0.0.1", 16784, AcceptServer)
|
60
|
+
EM.connect("127.0.0.1", 16784, Client).instance_variable_get("@signature")
|
61
|
+
}
|
62
|
+
|
63
|
+
assert_equal($cert_from_file, $cert_from_server)
|
64
|
+
assert($client_handshake_completed)
|
65
|
+
assert($server_handshake_completed)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_deny_server
|
69
|
+
$client_handshake_completed, $server_handshake_completed = false, false
|
70
|
+
EM.run {
|
71
|
+
EM.start_server("127.0.0.1", 16784, DenyServer)
|
72
|
+
EM.connect("127.0.0.1", 16784, Client)
|
73
|
+
}
|
74
|
+
|
75
|
+
assert_equal($cert_from_file, $cert_from_server)
|
76
|
+
assert(!$client_handshake_completed)
|
77
|
+
assert(!$server_handshake_completed)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
else
|
81
|
+
warn "EM built without SSL support, skipping tests in #{__FILE__}"
|
82
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class TestThreadedResource < Test::Unit::TestCase
|
2
|
+
def object
|
3
|
+
@object ||= {}
|
4
|
+
end
|
5
|
+
|
6
|
+
def resource
|
7
|
+
@resource = EM::ThreadedResource.new do
|
8
|
+
object
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
resource.shutdown
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_dispatch_completion
|
17
|
+
EM.run do
|
18
|
+
completion = resource.dispatch do |o|
|
19
|
+
o[:foo] = :bar
|
20
|
+
:foo
|
21
|
+
end
|
22
|
+
completion.callback do |result|
|
23
|
+
assert_equal :foo, result
|
24
|
+
EM.stop
|
25
|
+
end
|
26
|
+
end
|
27
|
+
assert_equal :bar, object[:foo]
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_dispatch_failure
|
31
|
+
completion = resource.dispatch do |o|
|
32
|
+
raise 'boom'
|
33
|
+
end
|
34
|
+
completion.errback do |error|
|
35
|
+
assert_kind_of RuntimeError, error
|
36
|
+
assert_equal 'boom', error.message
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_dispatch_threading
|
41
|
+
main = Thread.current
|
42
|
+
resource.dispatch do |o|
|
43
|
+
o[:dispatch_thread] = Thread.current
|
44
|
+
end
|
45
|
+
assert_not_equal main, object[:dispatch_thread]
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_shutdown
|
49
|
+
# This test should get improved sometime. The method returning thread is
|
50
|
+
# NOT an api that will be maintained.
|
51
|
+
assert !resource.shutdown.alive?
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require 'em_test_helper'
|
3
|
+
|
4
|
+
class TestEmTickLoop < Test::Unit::TestCase
|
5
|
+
def test_em_tick_loop
|
6
|
+
i = 0
|
7
|
+
EM.tick_loop { i += 1; EM.stop if i == 10 }
|
8
|
+
EM.run { EM.add_timer(1) { EM.stop } }
|
9
|
+
assert_equal i, 10
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_tick_loop_on_stop
|
13
|
+
t = nil
|
14
|
+
tick_loop = EM.tick_loop { :stop }
|
15
|
+
tick_loop.on_stop { t = true }
|
16
|
+
EM.run { EM.next_tick { EM.stop } }
|
17
|
+
assert t
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_start_twice
|
21
|
+
i = 0
|
22
|
+
s = 0
|
23
|
+
tick_loop = EM.tick_loop { i += 1; :stop }
|
24
|
+
tick_loop.on_stop { s += 1; EM.stop }
|
25
|
+
EM.run { EM.next_tick { EM.stop } }
|
26
|
+
assert_equal 1, i
|
27
|
+
assert_equal 1, s
|
28
|
+
tick_loop.start
|
29
|
+
EM.run { EM.next_tick { EM.stop } }
|
30
|
+
assert_equal 2, i
|
31
|
+
assert_equal 1, s # stop callbacks are only called once
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_stop
|
35
|
+
i, s = 0, 0
|
36
|
+
tick_loop = EM.tick_loop { i += 1 }
|
37
|
+
tick_loop.on_stop { s += 1 }
|
38
|
+
EM.run { EM.next_tick { tick_loop.stop; EM.next_tick { EM.stop } } }
|
39
|
+
assert tick_loop.stopped?
|
40
|
+
assert_equal 1, i
|
41
|
+
assert_equal 1, s
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_immediate_stops
|
45
|
+
s = 0
|
46
|
+
tick_loop = EM::TickLoop.new { }
|
47
|
+
tick_loop.on_stop { s += 1 }
|
48
|
+
tick_loop.on_stop { s += 1 }
|
49
|
+
assert_equal 2, s
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_stopped
|
53
|
+
tick_loop = EM::TickLoop.new { }
|
54
|
+
assert tick_loop.stopped?
|
55
|
+
tick_loop.start
|
56
|
+
assert !tick_loop.stopped?
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
|
3
|
+
class TestTimers < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_timer_with_block
|
6
|
+
x = false
|
7
|
+
EM.run {
|
8
|
+
EM::Timer.new(0) {
|
9
|
+
x = true
|
10
|
+
EM.stop
|
11
|
+
}
|
12
|
+
}
|
13
|
+
assert x
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_timer_with_proc
|
17
|
+
x = false
|
18
|
+
EM.run {
|
19
|
+
EM::Timer.new(0, proc {
|
20
|
+
x = true
|
21
|
+
EM.stop
|
22
|
+
})
|
23
|
+
}
|
24
|
+
assert x
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_timer_cancel
|
28
|
+
assert_nothing_raised do
|
29
|
+
EM.run {
|
30
|
+
timer = EM::Timer.new(0.01) { flunk "Timer was not cancelled." }
|
31
|
+
timer.cancel
|
32
|
+
|
33
|
+
EM.add_timer(0.02) { EM.stop }
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_periodic_timer
|
39
|
+
x = 0
|
40
|
+
EM.run {
|
41
|
+
EM::PeriodicTimer.new(0.01) do
|
42
|
+
x += 1
|
43
|
+
EM.stop if x == 4
|
44
|
+
end
|
45
|
+
}
|
46
|
+
|
47
|
+
assert_equal 4, x
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_add_periodic_timer
|
51
|
+
x = 0
|
52
|
+
EM.run {
|
53
|
+
t = EM.add_periodic_timer(0.01) do
|
54
|
+
x += 1
|
55
|
+
EM.stop if x == 4
|
56
|
+
end
|
57
|
+
assert t.respond_to?(:cancel)
|
58
|
+
}
|
59
|
+
assert_equal 4, x
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_periodic_timer_cancel
|
63
|
+
x = 0
|
64
|
+
EM.run {
|
65
|
+
pt = EM::PeriodicTimer.new(0.01) { x += 1 }
|
66
|
+
pt.cancel
|
67
|
+
EM::Timer.new(0.02) { EM.stop }
|
68
|
+
}
|
69
|
+
assert_equal 0, x
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_add_periodic_timer_cancel
|
73
|
+
x = 0
|
74
|
+
EM.run {
|
75
|
+
pt = EM.add_periodic_timer(0.01) { x += 1 }
|
76
|
+
EM.cancel_timer(pt)
|
77
|
+
EM.add_timer(0.02) { EM.stop }
|
78
|
+
}
|
79
|
+
assert_equal 0, x
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_periodic_timer_self_cancel
|
83
|
+
x = 0
|
84
|
+
EM.run {
|
85
|
+
pt = EM::PeriodicTimer.new(0) {
|
86
|
+
x += 1
|
87
|
+
if x == 4
|
88
|
+
pt.cancel
|
89
|
+
EM.stop
|
90
|
+
end
|
91
|
+
}
|
92
|
+
}
|
93
|
+
assert_equal 4, x
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# This test is only applicable to compiled versions of the reactor.
|
98
|
+
# Pure ruby and java versions have no built-in limit on the number of outstanding timers.
|
99
|
+
unless [:pure_ruby, :java].include? EM.library_type
|
100
|
+
def test_timer_change_max_outstanding
|
101
|
+
defaults = EM.get_max_timers
|
102
|
+
EM.set_max_timers(100)
|
103
|
+
|
104
|
+
one_hundred_one_timers = lambda do
|
105
|
+
101.times { EM.add_timer(0.01) {} }
|
106
|
+
EM.stop
|
107
|
+
end
|
108
|
+
|
109
|
+
assert_raises(RuntimeError) do
|
110
|
+
EM.run( &one_hundred_one_timers )
|
111
|
+
end
|
112
|
+
|
113
|
+
EM.set_max_timers( 101 )
|
114
|
+
|
115
|
+
assert_nothing_raised do
|
116
|
+
EM.run( &one_hundred_one_timers )
|
117
|
+
end
|
118
|
+
ensure
|
119
|
+
EM.set_max_timers(defaults)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
data/tests/test_ud.rb
ADDED
data/tests/test_udp46.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
|
3
|
+
class TestUDP46 < Test::Unit::TestCase
|
4
|
+
|
5
|
+
# this is a bit brittle. Maybe do not test for the actual error...
|
6
|
+
WANT_ALL = [
|
7
|
+
( RUBY_PLATFORM =~ /darwin1/ and # not an error in Linux (!?),
|
8
|
+
# strange handling in OSX 10.5.x (darwin9)
|
9
|
+
["::1", "::241.1.2.3", 5555, Errno::EHOSTUNREACH]),
|
10
|
+
["::1", "241.2.3.4", 5555,
|
11
|
+
(RUBY_PLATFORM =~ /linux/ ? Errno::ENETUNREACH : Errno::EINVAL)],
|
12
|
+
["127.0.0.1", "241.4.5.6", 5555,
|
13
|
+
(RUBY_PLATFORM =~ /linux/ ? Errno::EINVAL : Errno::ENETUNREACH)]
|
14
|
+
].compact
|
15
|
+
|
16
|
+
# Open a UDP socket listening on, say, ::1, and try to send a UDP
|
17
|
+
# datagram to IP address, say, ::241.1.2.3 (so no network route).
|
18
|
+
# Without the error handling fix, it makes EM close the UDP socket.
|
19
|
+
# Now fixed: https://github.com/eventmachine/eventmachine/issues/276
|
20
|
+
def test_udp_no_route
|
21
|
+
WANT_ALL.each do |want|
|
22
|
+
@@udp_socket_alive = false
|
23
|
+
@@udp_socket_unbind_cause = nil
|
24
|
+
@@error_came_in = false
|
25
|
+
|
26
|
+
EM.run do
|
27
|
+
|
28
|
+
EM::open_datagram_socket(want[0], next_port, EM::Connection) do |c|
|
29
|
+
c.send_error_handling = :ERRORHANDLING_REPORT
|
30
|
+
|
31
|
+
def c.unbind cause=nil
|
32
|
+
@@udp_socket_unbind_cause = cause
|
33
|
+
EM.stop
|
34
|
+
end
|
35
|
+
|
36
|
+
def c.receive_senderror(error, data)
|
37
|
+
@@error_came_in = [error, data]
|
38
|
+
end
|
39
|
+
|
40
|
+
c.send_datagram "no-route", want[1], want[2]
|
41
|
+
EM.add_timer(0.2) do
|
42
|
+
@@udp_socket_alive = true unless c.error?
|
43
|
+
EM.stop
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
assert @@udp_socket_alive, "UDP socket was killed (unbind cause: #{@@udp_socket_unbind_cause})"
|
50
|
+
assert_equal [want[3], [want[1], want[2].to_s]], @@error_came_in
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'em_test_helper'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
class TestUnbindReason < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class StubConnection < EM::Connection
|
7
|
+
attr_reader :error
|
8
|
+
def unbind(reason = nil)
|
9
|
+
@error = reason
|
10
|
+
EM.stop
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_connect_timeout
|
15
|
+
error = nil
|
16
|
+
EM.run {
|
17
|
+
conn = EM.connect 'google.com', 81, Module.new{ |m|
|
18
|
+
m.send(:define_method, :unbind) do |reason|
|
19
|
+
error = reason
|
20
|
+
EM.stop
|
21
|
+
end
|
22
|
+
}
|
23
|
+
conn.pending_connect_timeout = 0.1
|
24
|
+
}
|
25
|
+
assert_equal Errno::ETIMEDOUT, error
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_connect_refused
|
29
|
+
error = nil
|
30
|
+
EM.run {
|
31
|
+
EM.connect '127.0.0.1', 12388, Module.new{ |m|
|
32
|
+
m.send(:define_method, :unbind) do |reason|
|
33
|
+
error = reason
|
34
|
+
EM.stop
|
35
|
+
end
|
36
|
+
}
|
37
|
+
}
|
38
|
+
assert_equal Errno::ECONNREFUSED, error
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_optional_argument
|
42
|
+
conn = nil
|
43
|
+
EM.run {
|
44
|
+
conn = EM.connect '127.0.0.1', 12388, StubConnection
|
45
|
+
}
|
46
|
+
assert_equal Errno::ECONNREFUSED, conn.error
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,319 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eventmachine-with-ipv6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.beta.4.ipv6.0
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Francis Cianfrocca
|
9
|
+
- Aman Gupta
|
10
|
+
- hacked by Carsten Bormann
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2012-02-12 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rake-compiler
|
18
|
+
requirement: &70228759344540 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - =
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.7.9
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *70228759344540
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yard
|
29
|
+
requirement: &70228759343880 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.7.2
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *70228759343880
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: bluecloth
|
40
|
+
requirement: &70228759343440 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *70228759343440
|
49
|
+
description: ! 'EventMachine implements a fast, single-threaded engine for arbitrary
|
50
|
+
network
|
51
|
+
|
52
|
+
communications. It''s extremely easy to use in Ruby. EventMachine wraps all
|
53
|
+
|
54
|
+
interactions with IP sockets, allowing programs to concentrate on the
|
55
|
+
|
56
|
+
implementation of network protocols. It can be used to create both network
|
57
|
+
|
58
|
+
servers and clients. To create a server or client, a Ruby program only needs
|
59
|
+
|
60
|
+
to specify the IP address and port, and provide a Module that implements the
|
61
|
+
|
62
|
+
communications protocol. Implementations of several standard network protocols
|
63
|
+
|
64
|
+
are provided with the package, primarily to serve as examples. The real goal
|
65
|
+
|
66
|
+
of EventMachine is to enable programs to easily interface with other programs
|
67
|
+
|
68
|
+
using TCP/IP, especially if custom protocols are required.
|
69
|
+
|
70
|
+
|
71
|
+
The present alternative version ''eventmachine-with-ipv6'' contains some
|
72
|
+
|
73
|
+
crucial fixes for datagrams (UDP) and IPv6 developed since 2010 by
|
74
|
+
|
75
|
+
Carsten Bormann and Iñaki Baz Castillo. This is needed for many
|
76
|
+
|
77
|
+
applications in 2012, but might detract from the stability achieved
|
78
|
+
|
79
|
+
for other typical uses of the base eventmachine. It is otherwise
|
80
|
+
|
81
|
+
identical with base eventmachine. Install either base eventmachine or
|
82
|
+
|
83
|
+
this version eventmachine-with-ipv6. If you have installed both, use
|
84
|
+
|
85
|
+
gem ''eventmachine-with-ipv6''
|
86
|
+
|
87
|
+
before
|
88
|
+
|
89
|
+
require ''eventmachine''
|
90
|
+
|
91
|
+
Alternatively use Bundler and write this in your gemfile:
|
92
|
+
|
93
|
+
gem "eventmachine", :git => "git://github.com/cabo/eventmachine"
|
94
|
+
|
95
|
+
|
96
|
+
Please send all bugs in this version to https://github.com/cabo/eventmachine/issues
|
97
|
+
|
98
|
+
'
|
99
|
+
email:
|
100
|
+
- garbagecat10@gmail.com
|
101
|
+
- aman@tmm1.net
|
102
|
+
- cabo@tzi.org
|
103
|
+
executables: []
|
104
|
+
extensions:
|
105
|
+
- ext/extconf.rb
|
106
|
+
- ext/fastfilereader/extconf.rb
|
107
|
+
extra_rdoc_files:
|
108
|
+
- README.md
|
109
|
+
- docs/DocumentationGuidesIndex.md
|
110
|
+
- docs/GettingStarted.md
|
111
|
+
- docs/old/ChangeLog
|
112
|
+
- docs/old/DEFERRABLES
|
113
|
+
- docs/old/EPOLL
|
114
|
+
- docs/old/INSTALL
|
115
|
+
- docs/old/KEYBOARD
|
116
|
+
- docs/old/LEGAL
|
117
|
+
- docs/old/LIGHTWEIGHT_CONCURRENCY
|
118
|
+
- docs/old/PURE_RUBY
|
119
|
+
- docs/old/RELEASE_NOTES
|
120
|
+
- docs/old/SMTP
|
121
|
+
- docs/old/SPAWNED_PROCESSES
|
122
|
+
- docs/old/TODO
|
123
|
+
files:
|
124
|
+
- .gitignore
|
125
|
+
- .yardopts
|
126
|
+
- FORK.md
|
127
|
+
- GNU
|
128
|
+
- Gemfile
|
129
|
+
- LICENSE
|
130
|
+
- README.md
|
131
|
+
- Rakefile
|
132
|
+
- docs/DocumentationGuidesIndex.md
|
133
|
+
- docs/GettingStarted.md
|
134
|
+
- docs/old/ChangeLog
|
135
|
+
- docs/old/DEFERRABLES
|
136
|
+
- docs/old/EPOLL
|
137
|
+
- docs/old/INSTALL
|
138
|
+
- docs/old/KEYBOARD
|
139
|
+
- docs/old/LEGAL
|
140
|
+
- docs/old/LIGHTWEIGHT_CONCURRENCY
|
141
|
+
- docs/old/PURE_RUBY
|
142
|
+
- docs/old/RELEASE_NOTES
|
143
|
+
- docs/old/SMTP
|
144
|
+
- docs/old/SPAWNED_PROCESSES
|
145
|
+
- docs/old/TODO
|
146
|
+
- eventmachine.gemspec
|
147
|
+
- examples/guides/getting_started/01_eventmachine_echo_server.rb
|
148
|
+
- examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
|
149
|
+
- examples/guides/getting_started/03_simple_chat_server.rb
|
150
|
+
- examples/guides/getting_started/04_simple_chat_server_step_one.rb
|
151
|
+
- examples/guides/getting_started/05_simple_chat_server_step_two.rb
|
152
|
+
- examples/guides/getting_started/06_simple_chat_server_step_three.rb
|
153
|
+
- examples/guides/getting_started/07_simple_chat_server_step_four.rb
|
154
|
+
- examples/guides/getting_started/08_simple_chat_server_step_five.rb
|
155
|
+
- examples/old/ex_channel.rb
|
156
|
+
- examples/old/ex_queue.rb
|
157
|
+
- examples/old/ex_tick_loop_array.rb
|
158
|
+
- examples/old/ex_tick_loop_counter.rb
|
159
|
+
- examples/old/helper.rb
|
160
|
+
- ext/binder.cpp
|
161
|
+
- ext/binder.h
|
162
|
+
- ext/cmain.cpp
|
163
|
+
- ext/ed.cpp
|
164
|
+
- ext/ed.h
|
165
|
+
- ext/em.cpp
|
166
|
+
- ext/em.h
|
167
|
+
- ext/eventmachine.h
|
168
|
+
- ext/extconf.rb
|
169
|
+
- ext/fastfilereader/extconf.rb
|
170
|
+
- ext/fastfilereader/mapper.cpp
|
171
|
+
- ext/fastfilereader/mapper.h
|
172
|
+
- ext/fastfilereader/rubymain.cpp
|
173
|
+
- ext/kb.cpp
|
174
|
+
- ext/page.cpp
|
175
|
+
- ext/page.h
|
176
|
+
- ext/pipe.cpp
|
177
|
+
- ext/project.h
|
178
|
+
- ext/rubymain.cpp
|
179
|
+
- ext/ssl.cpp
|
180
|
+
- ext/ssl.h
|
181
|
+
- java/.classpath
|
182
|
+
- java/.project
|
183
|
+
- java/src/com/rubyeventmachine/EmReactor.java
|
184
|
+
- java/src/com/rubyeventmachine/EmReactorException.java
|
185
|
+
- java/src/com/rubyeventmachine/EventableChannel.java
|
186
|
+
- java/src/com/rubyeventmachine/EventableDatagramChannel.java
|
187
|
+
- java/src/com/rubyeventmachine/EventableSocketChannel.java
|
188
|
+
- lib/em/buftok.rb
|
189
|
+
- lib/em/callback.rb
|
190
|
+
- lib/em/channel.rb
|
191
|
+
- lib/em/completion.rb
|
192
|
+
- lib/em/connection.rb
|
193
|
+
- lib/em/deferrable.rb
|
194
|
+
- lib/em/deferrable/pool.rb
|
195
|
+
- lib/em/file_watch.rb
|
196
|
+
- lib/em/future.rb
|
197
|
+
- lib/em/iterator.rb
|
198
|
+
- lib/em/messages.rb
|
199
|
+
- lib/em/pool.rb
|
200
|
+
- lib/em/process_watch.rb
|
201
|
+
- lib/em/processes.rb
|
202
|
+
- lib/em/protocols.rb
|
203
|
+
- lib/em/protocols/header_and_content.rb
|
204
|
+
- lib/em/protocols/httpclient.rb
|
205
|
+
- lib/em/protocols/httpclient2.rb
|
206
|
+
- lib/em/protocols/line_and_text.rb
|
207
|
+
- lib/em/protocols/line_protocol.rb
|
208
|
+
- lib/em/protocols/linetext2.rb
|
209
|
+
- lib/em/protocols/memcache.rb
|
210
|
+
- lib/em/protocols/object_protocol.rb
|
211
|
+
- lib/em/protocols/postgres3.rb
|
212
|
+
- lib/em/protocols/saslauth.rb
|
213
|
+
- lib/em/protocols/smtpclient.rb
|
214
|
+
- lib/em/protocols/smtpserver.rb
|
215
|
+
- lib/em/protocols/socks4.rb
|
216
|
+
- lib/em/protocols/stomp.rb
|
217
|
+
- lib/em/protocols/tcptest.rb
|
218
|
+
- lib/em/pure_ruby.rb
|
219
|
+
- lib/em/queue.rb
|
220
|
+
- lib/em/resolver.rb
|
221
|
+
- lib/em/spawnable.rb
|
222
|
+
- lib/em/streamer.rb
|
223
|
+
- lib/em/threaded_resource.rb
|
224
|
+
- lib/em/tick_loop.rb
|
225
|
+
- lib/em/timers.rb
|
226
|
+
- lib/em/version.rb
|
227
|
+
- lib/eventmachine.rb
|
228
|
+
- lib/jeventmachine.rb
|
229
|
+
- rakelib/cpp.rake_example
|
230
|
+
- rakelib/package.rake
|
231
|
+
- rakelib/test.rake
|
232
|
+
- tests/client.crt
|
233
|
+
- tests/client.key
|
234
|
+
- tests/em_test_helper.rb
|
235
|
+
- tests/test_attach.rb
|
236
|
+
- tests/test_basic.rb
|
237
|
+
- tests/test_channel.rb
|
238
|
+
- tests/test_completion.rb
|
239
|
+
- tests/test_connection_count.rb
|
240
|
+
- tests/test_defer.rb
|
241
|
+
- tests/test_deferrable.rb
|
242
|
+
- tests/test_epoll.rb
|
243
|
+
- tests/test_error_handler.rb
|
244
|
+
- tests/test_exc.rb
|
245
|
+
- tests/test_file_watch.rb
|
246
|
+
- tests/test_futures.rb
|
247
|
+
- tests/test_get_sock_opt.rb
|
248
|
+
- tests/test_handler_check.rb
|
249
|
+
- tests/test_hc.rb
|
250
|
+
- tests/test_httpclient.rb
|
251
|
+
- tests/test_httpclient2.rb
|
252
|
+
- tests/test_inactivity_timeout.rb
|
253
|
+
- tests/test_ipv4.rb
|
254
|
+
- tests/test_ipv6.rb
|
255
|
+
- tests/test_kb.rb
|
256
|
+
- tests/test_ltp.rb
|
257
|
+
- tests/test_ltp2.rb
|
258
|
+
- tests/test_next_tick.rb
|
259
|
+
- tests/test_object_protocol.rb
|
260
|
+
- tests/test_pause.rb
|
261
|
+
- tests/test_pending_connect_timeout.rb
|
262
|
+
- tests/test_pool.rb
|
263
|
+
- tests/test_process_watch.rb
|
264
|
+
- tests/test_processes.rb
|
265
|
+
- tests/test_proxy_connection.rb
|
266
|
+
- tests/test_pure.rb
|
267
|
+
- tests/test_queue.rb
|
268
|
+
- tests/test_resolver.rb
|
269
|
+
- tests/test_running.rb
|
270
|
+
- tests/test_sasl.rb
|
271
|
+
- tests/test_send_file.rb
|
272
|
+
- tests/test_servers.rb
|
273
|
+
- tests/test_set_sock_opt.rb
|
274
|
+
- tests/test_shutdown_hooks.rb
|
275
|
+
- tests/test_smtpclient.rb
|
276
|
+
- tests/test_smtpserver.rb
|
277
|
+
- tests/test_spawn.rb
|
278
|
+
- tests/test_ssl_args.rb
|
279
|
+
- tests/test_ssl_methods.rb
|
280
|
+
- tests/test_ssl_verify.rb
|
281
|
+
- tests/test_threaded_resource.rb
|
282
|
+
- tests/test_tick_loop.rb
|
283
|
+
- tests/test_timers.rb
|
284
|
+
- tests/test_ud.rb
|
285
|
+
- tests/test_udp46.rb
|
286
|
+
- tests/test_unbind_reason.rb
|
287
|
+
homepage: http://github.com/cabo/eventmachine
|
288
|
+
licenses: []
|
289
|
+
post_install_message:
|
290
|
+
rdoc_options:
|
291
|
+
- --title
|
292
|
+
- EventMachine
|
293
|
+
- --main
|
294
|
+
- README.md
|
295
|
+
- -x
|
296
|
+
- lib/em/version
|
297
|
+
- -x
|
298
|
+
- lib/jeventmachine
|
299
|
+
require_paths:
|
300
|
+
- lib
|
301
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
302
|
+
none: false
|
303
|
+
requirements:
|
304
|
+
- - ! '>='
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0'
|
307
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
308
|
+
none: false
|
309
|
+
requirements:
|
310
|
+
- - ! '>'
|
311
|
+
- !ruby/object:Gem::Version
|
312
|
+
version: 1.3.1
|
313
|
+
requirements: []
|
314
|
+
rubyforge_project:
|
315
|
+
rubygems_version: 1.8.10
|
316
|
+
signing_key:
|
317
|
+
specification_version: 3
|
318
|
+
summary: Ruby/EventMachine library with UDP and IPv6 fixes
|
319
|
+
test_files: []
|