wj_eventmachine 1.3.0.dev.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +179 -0
- data/GNU +281 -0
- data/LICENSE +60 -0
- data/README.md +110 -0
- data/docs/DocumentationGuidesIndex.md +27 -0
- data/docs/GettingStarted.md +520 -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/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 +52 -0
- data/ext/cmain.cpp +1046 -0
- data/ext/ed.cpp +2238 -0
- data/ext/ed.h +460 -0
- data/ext/em.cpp +2378 -0
- data/ext/em.h +266 -0
- data/ext/eventmachine.h +152 -0
- data/ext/extconf.rb +285 -0
- data/ext/fastfilereader/extconf.rb +120 -0
- data/ext/fastfilereader/mapper.cpp +214 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +126 -0
- data/ext/kb.cpp +79 -0
- data/ext/page.cpp +107 -0
- data/ext/page.h +51 -0
- data/ext/pipe.cpp +354 -0
- data/ext/project.h +174 -0
- data/ext/rubymain.cpp +1610 -0
- data/ext/ssl.cpp +627 -0
- data/ext/ssl.h +103 -0
- data/ext/wait_for_single_fd.h +36 -0
- data/java/.classpath +8 -0
- data/java/.project +17 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +625 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EmReactorInterface.java +70 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +72 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +201 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +415 -0
- data/java/src/com/rubyeventmachine/NullEmReactor.java +157 -0
- data/java/src/com/rubyeventmachine/NullEventableChannel.java +81 -0
- data/lib/em/buftok.rb +59 -0
- data/lib/em/callback.rb +58 -0
- data/lib/em/channel.rb +69 -0
- data/lib/em/completion.rb +307 -0
- data/lib/em/connection.rb +776 -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/io_streamer.rb +68 -0
- data/lib/em/iterator.rb +252 -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 +37 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +303 -0
- data/lib/em/protocols/httpclient2.rb +602 -0
- data/lib/em/protocols/line_and_text.rb +125 -0
- data/lib/em/protocols/line_protocol.rb +33 -0
- data/lib/em/protocols/linetext2.rb +179 -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 +394 -0
- data/lib/em/protocols/smtpserver.rb +666 -0
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/protocols/stomp.rb +205 -0
- data/lib/em/protocols/tcptest.rb +54 -0
- data/lib/em/pure_ruby.rb +1299 -0
- data/lib/em/queue.rb +80 -0
- data/lib/em/resolver.rb +232 -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 +1602 -0
- data/lib/jeventmachine.rb +318 -0
- data/rakelib/package.rake +120 -0
- data/rakelib/test.rake +6 -0
- data/rakelib/test_pure.rake +11 -0
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/dhparam.pem +13 -0
- data/tests/em_ssl_handlers.rb +153 -0
- data/tests/em_test_helper.rb +198 -0
- data/tests/jruby/test_jeventmachine.rb +38 -0
- data/tests/test_attach.rb +199 -0
- data/tests/test_basic.rb +321 -0
- data/tests/test_channel.rb +75 -0
- data/tests/test_completion.rb +178 -0
- data/tests/test_connection_count.rb +83 -0
- data/tests/test_connection_write.rb +35 -0
- data/tests/test_defer.rb +35 -0
- data/tests/test_deferrable.rb +35 -0
- data/tests/test_epoll.rb +141 -0
- data/tests/test_error_handler.rb +38 -0
- data/tests/test_exc.rb +37 -0
- data/tests/test_file_watch.rb +86 -0
- data/tests/test_fork.rb +75 -0
- data/tests/test_futures.rb +170 -0
- data/tests/test_handler_check.rb +35 -0
- data/tests/test_hc.rb +155 -0
- data/tests/test_httpclient.rb +238 -0
- data/tests/test_httpclient2.rb +132 -0
- data/tests/test_idle_connection.rb +31 -0
- data/tests/test_inactivity_timeout.rb +102 -0
- data/tests/test_io_streamer.rb +47 -0
- data/tests/test_ipv4.rb +96 -0
- data/tests/test_ipv6.rb +107 -0
- data/tests/test_iterator.rb +122 -0
- data/tests/test_kb.rb +28 -0
- data/tests/test_keepalive.rb +113 -0
- data/tests/test_line_protocol.rb +33 -0
- data/tests/test_ltp.rb +155 -0
- data/tests/test_ltp2.rb +332 -0
- data/tests/test_many_fds.rb +21 -0
- data/tests/test_next_tick.rb +104 -0
- data/tests/test_object_protocol.rb +36 -0
- data/tests/test_pause.rb +109 -0
- data/tests/test_pending_connect_timeout.rb +52 -0
- data/tests/test_pool.rb +196 -0
- data/tests/test_process_watch.rb +50 -0
- data/tests/test_processes.rb +128 -0
- data/tests/test_proxy_connection.rb +180 -0
- data/tests/test_pure.rb +156 -0
- data/tests/test_queue.rb +64 -0
- data/tests/test_resolver.rb +129 -0
- data/tests/test_running.rb +14 -0
- data/tests/test_sasl.rb +46 -0
- data/tests/test_send_file.rb +217 -0
- data/tests/test_servers.rb +32 -0
- data/tests/test_shutdown_hooks.rb +23 -0
- data/tests/test_smtpclient.rb +75 -0
- data/tests/test_smtpserver.rb +90 -0
- data/tests/test_sock_opt.rb +53 -0
- data/tests/test_spawn.rb +290 -0
- data/tests/test_ssl_args.rb +41 -0
- data/tests/test_ssl_dhparam.rb +57 -0
- data/tests/test_ssl_ecdh_curve.rb +57 -0
- data/tests/test_ssl_extensions.rb +24 -0
- data/tests/test_ssl_methods.rb +31 -0
- data/tests/test_ssl_protocols.rb +190 -0
- data/tests/test_ssl_verify.rb +52 -0
- data/tests/test_stomp.rb +38 -0
- data/tests/test_system.rb +46 -0
- data/tests/test_threaded_resource.rb +68 -0
- data/tests/test_tick_loop.rb +58 -0
- data/tests/test_timers.rb +150 -0
- data/tests/test_ud.rb +8 -0
- data/tests/test_unbind_reason.rb +40 -0
- metadata +384 -0
data/tests/test_stomp.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'em_test_helper'
|
2
|
+
|
3
|
+
class TestStomp < Test::Unit::TestCase
|
4
|
+
CONTENT_LENGTH_REGEX = /^content-length: (\d+)$/
|
5
|
+
|
6
|
+
def bytesize(str)
|
7
|
+
str = str.to_s
|
8
|
+
size = str.bytesize if str.respond_to?(:bytesize) # bytesize added in 1.9
|
9
|
+
size || str.size
|
10
|
+
end
|
11
|
+
|
12
|
+
class TStomp
|
13
|
+
include EM::P::Stomp
|
14
|
+
|
15
|
+
def last_sent_content_length
|
16
|
+
@sent && Integer(@sent[CONTENT_LENGTH_REGEX, 1])
|
17
|
+
end
|
18
|
+
|
19
|
+
def send_data(string)
|
20
|
+
@sent = string
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_content_length_in_bytes
|
25
|
+
connection = TStomp.new
|
26
|
+
|
27
|
+
queue = "queue"
|
28
|
+
failure_message = "header content-length is not the byte size of last sent body"
|
29
|
+
|
30
|
+
body = "test"
|
31
|
+
connection.send queue, body
|
32
|
+
assert_equal bytesize(body), connection.last_sent_content_length, failure_message
|
33
|
+
|
34
|
+
body = "test\u221A"
|
35
|
+
connection.send queue, body
|
36
|
+
assert_equal bytesize(body), connection.last_sent_content_length, failure_message
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require_relative 'em_test_helper'
|
3
|
+
|
4
|
+
class TestSystem < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@filename = File.expand_path("../я манал dump.txt", __FILE__)
|
7
|
+
@test_data = 'a' * 100
|
8
|
+
File.open(@filename, 'w'){|f| f.write(@test_data)}
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_system
|
12
|
+
omit_if(windows?)
|
13
|
+
|
14
|
+
result = nil
|
15
|
+
status = nil
|
16
|
+
EM.run {
|
17
|
+
EM.system('cat', @filename){|out, state|
|
18
|
+
result = out
|
19
|
+
status = state.exitstatus
|
20
|
+
EM.stop
|
21
|
+
}
|
22
|
+
}
|
23
|
+
assert_equal(0, status)
|
24
|
+
assert_equal(@test_data, result)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_system_with_string
|
28
|
+
omit_if(windows?)
|
29
|
+
|
30
|
+
result = nil
|
31
|
+
status = nil
|
32
|
+
EM.run {
|
33
|
+
EM.system("cat '#@filename'"){|out, state|
|
34
|
+
result = out
|
35
|
+
status = state.exitstatus
|
36
|
+
EM.stop
|
37
|
+
}
|
38
|
+
}
|
39
|
+
assert_equal(0, status)
|
40
|
+
assert_equal(@test_data, result)
|
41
|
+
end
|
42
|
+
|
43
|
+
def teardown
|
44
|
+
File.unlink(@filename)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative 'em_test_helper'
|
2
|
+
|
3
|
+
class TestThreadedResource < Test::Unit::TestCase
|
4
|
+
def object
|
5
|
+
@object ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def resource
|
9
|
+
@resource = EM::ThreadedResource.new do
|
10
|
+
object
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
resource.shutdown
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_dispatch_completion
|
19
|
+
EM.run do
|
20
|
+
EM.add_timer(3) do
|
21
|
+
EM.stop
|
22
|
+
if ENV['CI'].casecmp('true').zero? and RUBY_PLATFORM[/darwin/]
|
23
|
+
notify "Intermittent Travis MacOS: Resource dispatch timed out"
|
24
|
+
return
|
25
|
+
else
|
26
|
+
assert false, 'Resource dispatch timed out'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
completion = resource.dispatch do |o|
|
30
|
+
o[:foo] = :bar
|
31
|
+
:foo
|
32
|
+
end
|
33
|
+
completion.callback do |result|
|
34
|
+
assert_equal :foo, result
|
35
|
+
EM.stop
|
36
|
+
end
|
37
|
+
completion.errback do |error|
|
38
|
+
EM.stop
|
39
|
+
assert false, "Unexpected error: #{error.message}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
assert_equal :bar, object[:foo]
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_dispatch_failure
|
46
|
+
completion = resource.dispatch do |o|
|
47
|
+
raise 'boom'
|
48
|
+
end
|
49
|
+
completion.errback do |error|
|
50
|
+
assert_kind_of RuntimeError, error
|
51
|
+
assert_equal 'boom', error.message
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_dispatch_threading
|
56
|
+
main = Thread.current
|
57
|
+
resource.dispatch do |o|
|
58
|
+
o[:dispatch_thread] = Thread.current
|
59
|
+
end
|
60
|
+
assert_not_equal main, object[:dispatch_thread]
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_shutdown
|
64
|
+
# This test should get improved sometime. The method returning thread is
|
65
|
+
# NOT an api that will be maintained.
|
66
|
+
assert !resource.shutdown.alive?
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative 'em_test_helper'
|
2
|
+
|
3
|
+
class TestEmTickLoop < Test::Unit::TestCase
|
4
|
+
def test_em_tick_loop
|
5
|
+
i = 0
|
6
|
+
EM.tick_loop { i += 1; EM.stop if i == 10 }
|
7
|
+
EM.run { EM.add_timer(1) { EM.stop } }
|
8
|
+
assert_equal i, 10
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_tick_loop_on_stop
|
12
|
+
t = nil
|
13
|
+
tick_loop = EM.tick_loop { :stop }
|
14
|
+
tick_loop.on_stop { t = true }
|
15
|
+
EM.run { EM.next_tick { EM.stop } }
|
16
|
+
assert t
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_start_twice
|
20
|
+
i = 0
|
21
|
+
s = 0
|
22
|
+
tick_loop = EM.tick_loop { i += 1; :stop }
|
23
|
+
tick_loop.on_stop { s += 1; EM.stop }
|
24
|
+
EM.run { EM.next_tick { EM.stop } }
|
25
|
+
assert_equal 1, i
|
26
|
+
assert_equal 1, s
|
27
|
+
tick_loop.start
|
28
|
+
EM.run { EM.next_tick { EM.stop } }
|
29
|
+
assert_equal 2, i
|
30
|
+
assert_equal 1, s # stop callbacks are only called once
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_stop
|
34
|
+
i, s = 0, 0
|
35
|
+
tick_loop = EM.tick_loop { i += 1 }
|
36
|
+
tick_loop.on_stop { s += 1 }
|
37
|
+
EM.run { EM.next_tick { tick_loop.stop; EM.next_tick { EM.stop } } }
|
38
|
+
assert tick_loop.stopped?
|
39
|
+
assert_equal 1, i
|
40
|
+
assert_equal 1, s
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_immediate_stops
|
44
|
+
s = 0
|
45
|
+
tick_loop = EM::TickLoop.new { }
|
46
|
+
tick_loop.on_stop { s += 1 }
|
47
|
+
tick_loop.on_stop { s += 1 }
|
48
|
+
assert_equal 2, s
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_stopped
|
52
|
+
tick_loop = EM::TickLoop.new { }
|
53
|
+
assert tick_loop.stopped?
|
54
|
+
tick_loop.start
|
55
|
+
assert !tick_loop.stopped?
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require_relative '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
|
+
def test_oneshot_timer_large_future_value
|
97
|
+
large_value = 11948602000
|
98
|
+
EM.run {
|
99
|
+
EM.add_timer(large_value) { EM.stop }
|
100
|
+
EM.add_timer(0.02) { EM.stop }
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_add_timer_increments_timer_count
|
105
|
+
EM.run {
|
106
|
+
n = EM.get_timer_count
|
107
|
+
EM::Timer.new(0.01) {
|
108
|
+
EM.stop
|
109
|
+
}
|
110
|
+
assert_equal(n+1, EM.get_timer_count)
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_timer_run_decrements_timer_count
|
115
|
+
EM.run {
|
116
|
+
n = EM.get_timer_count
|
117
|
+
EM::Timer.new(0.01) {
|
118
|
+
assert_equal(n, EM.get_timer_count)
|
119
|
+
EM.stop
|
120
|
+
}
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
124
|
+
# This test is only applicable to compiled versions of the reactor.
|
125
|
+
# Pure ruby and java versions have no built-in limit on the number of outstanding timers.
|
126
|
+
unless [:pure_ruby, :java].include? EM.library_type
|
127
|
+
def test_timer_change_max_outstanding
|
128
|
+
defaults = EM.get_max_timers
|
129
|
+
EM.set_max_timers(100)
|
130
|
+
|
131
|
+
one_hundred_one_timers = lambda do
|
132
|
+
101.times { EM.add_timer(0.01) {} }
|
133
|
+
EM.stop
|
134
|
+
end
|
135
|
+
|
136
|
+
assert_raises(RuntimeError) do
|
137
|
+
EM.run( &one_hundred_one_timers )
|
138
|
+
end
|
139
|
+
|
140
|
+
EM.set_max_timers( 101 )
|
141
|
+
|
142
|
+
assert_nothing_raised do
|
143
|
+
EM.run( &one_hundred_one_timers )
|
144
|
+
end
|
145
|
+
ensure
|
146
|
+
EM.set_max_timers(defaults)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
data/tests/test_ud.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'em_test_helper'
|
2
|
+
|
3
|
+
class TestUnbindReason < Test::Unit::TestCase
|
4
|
+
|
5
|
+
class StubConnection < EM::Connection
|
6
|
+
attr_reader :error
|
7
|
+
def unbind(reason = nil)
|
8
|
+
@error = reason
|
9
|
+
EM.stop
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# RFC 5737 Address Blocks Reserved for Documentation
|
14
|
+
def test_connect_timeout
|
15
|
+
conn = nil
|
16
|
+
EM.run do
|
17
|
+
conn = EM.connect '192.0.2.0', 80, StubConnection
|
18
|
+
conn.pending_connect_timeout = 1
|
19
|
+
end
|
20
|
+
assert_equal Errno::ETIMEDOUT, conn.error
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_connect_refused
|
24
|
+
pend('FIXME: this test is broken on Windows') if windows?
|
25
|
+
conn = nil
|
26
|
+
EM.run do
|
27
|
+
conn = EM.connect '127.0.0.1', 12388, StubConnection
|
28
|
+
end
|
29
|
+
assert_equal Errno::ECONNREFUSED, conn.error
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_optional_argument
|
33
|
+
pend('FIXME: this test is broken on Windows') if windows?
|
34
|
+
conn = nil
|
35
|
+
EM.run do
|
36
|
+
conn = EM.connect '127.0.0.1', 12388, StubConnection
|
37
|
+
end
|
38
|
+
assert_equal Errno::ECONNREFUSED, conn.error
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,384 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wj_eventmachine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0.dev.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Francis Cianfrocca
|
8
|
+
- Aman Gupta
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: test-unit
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.2'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.2'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake-compiler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.1'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake-compiler-dock
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.6.3
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.6.3
|
56
|
+
description: |
|
57
|
+
EventMachine implements a fast, single-threaded engine for arbitrary network
|
58
|
+
communications. It's extremely easy to use in Ruby. EventMachine wraps all
|
59
|
+
interactions with IP sockets, allowing programs to concentrate on the
|
60
|
+
implementation of network protocols. It can be used to create both network
|
61
|
+
servers and clients. To create a server or client, a Ruby program only needs
|
62
|
+
to specify the IP address and port, and provide a Module that implements the
|
63
|
+
communications protocol. Implementations of several standard network protocols
|
64
|
+
are provided with the package, primarily to serve as examples. The real goal
|
65
|
+
of EventMachine is to enable programs to easily interface with other programs
|
66
|
+
using TCP/IP, especially if custom protocols are required.
|
67
|
+
email:
|
68
|
+
- garbagecat10@gmail.com
|
69
|
+
- aman@tmm1.net
|
70
|
+
executables: []
|
71
|
+
extensions:
|
72
|
+
- ext/extconf.rb
|
73
|
+
- ext/fastfilereader/extconf.rb
|
74
|
+
extra_rdoc_files:
|
75
|
+
- README.md
|
76
|
+
- docs/DocumentationGuidesIndex.md
|
77
|
+
- docs/GettingStarted.md
|
78
|
+
- docs/old/ChangeLog
|
79
|
+
- docs/old/DEFERRABLES
|
80
|
+
- docs/old/EPOLL
|
81
|
+
- docs/old/INSTALL
|
82
|
+
- docs/old/KEYBOARD
|
83
|
+
- docs/old/LEGAL
|
84
|
+
- docs/old/LIGHTWEIGHT_CONCURRENCY
|
85
|
+
- docs/old/PURE_RUBY
|
86
|
+
- docs/old/RELEASE_NOTES
|
87
|
+
- docs/old/SMTP
|
88
|
+
- docs/old/SPAWNED_PROCESSES
|
89
|
+
- docs/old/TODO
|
90
|
+
files:
|
91
|
+
- CHANGELOG.md
|
92
|
+
- GNU
|
93
|
+
- LICENSE
|
94
|
+
- README.md
|
95
|
+
- docs/DocumentationGuidesIndex.md
|
96
|
+
- docs/GettingStarted.md
|
97
|
+
- docs/old/ChangeLog
|
98
|
+
- docs/old/DEFERRABLES
|
99
|
+
- docs/old/EPOLL
|
100
|
+
- docs/old/INSTALL
|
101
|
+
- docs/old/KEYBOARD
|
102
|
+
- docs/old/LEGAL
|
103
|
+
- docs/old/LIGHTWEIGHT_CONCURRENCY
|
104
|
+
- docs/old/PURE_RUBY
|
105
|
+
- docs/old/RELEASE_NOTES
|
106
|
+
- docs/old/SMTP
|
107
|
+
- docs/old/SPAWNED_PROCESSES
|
108
|
+
- docs/old/TODO
|
109
|
+
- examples/guides/getting_started/01_eventmachine_echo_server.rb
|
110
|
+
- examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
|
111
|
+
- examples/guides/getting_started/03_simple_chat_server.rb
|
112
|
+
- examples/guides/getting_started/04_simple_chat_server_step_one.rb
|
113
|
+
- examples/guides/getting_started/05_simple_chat_server_step_two.rb
|
114
|
+
- examples/guides/getting_started/06_simple_chat_server_step_three.rb
|
115
|
+
- examples/guides/getting_started/07_simple_chat_server_step_four.rb
|
116
|
+
- examples/guides/getting_started/08_simple_chat_server_step_five.rb
|
117
|
+
- examples/old/ex_channel.rb
|
118
|
+
- examples/old/ex_queue.rb
|
119
|
+
- examples/old/ex_tick_loop_array.rb
|
120
|
+
- examples/old/ex_tick_loop_counter.rb
|
121
|
+
- examples/old/helper.rb
|
122
|
+
- ext/binder.cpp
|
123
|
+
- ext/binder.h
|
124
|
+
- ext/cmain.cpp
|
125
|
+
- ext/ed.cpp
|
126
|
+
- ext/ed.h
|
127
|
+
- ext/em.cpp
|
128
|
+
- ext/em.h
|
129
|
+
- ext/eventmachine.h
|
130
|
+
- ext/extconf.rb
|
131
|
+
- ext/fastfilereader/extconf.rb
|
132
|
+
- ext/fastfilereader/mapper.cpp
|
133
|
+
- ext/fastfilereader/mapper.h
|
134
|
+
- ext/fastfilereader/rubymain.cpp
|
135
|
+
- ext/kb.cpp
|
136
|
+
- ext/page.cpp
|
137
|
+
- ext/page.h
|
138
|
+
- ext/pipe.cpp
|
139
|
+
- ext/project.h
|
140
|
+
- ext/rubymain.cpp
|
141
|
+
- ext/ssl.cpp
|
142
|
+
- ext/ssl.h
|
143
|
+
- ext/wait_for_single_fd.h
|
144
|
+
- java/.classpath
|
145
|
+
- java/.project
|
146
|
+
- java/src/com/rubyeventmachine/EmReactor.java
|
147
|
+
- java/src/com/rubyeventmachine/EmReactorException.java
|
148
|
+
- java/src/com/rubyeventmachine/EmReactorInterface.java
|
149
|
+
- java/src/com/rubyeventmachine/EventableChannel.java
|
150
|
+
- java/src/com/rubyeventmachine/EventableDatagramChannel.java
|
151
|
+
- java/src/com/rubyeventmachine/EventableSocketChannel.java
|
152
|
+
- java/src/com/rubyeventmachine/NullEmReactor.java
|
153
|
+
- java/src/com/rubyeventmachine/NullEventableChannel.java
|
154
|
+
- lib/em/buftok.rb
|
155
|
+
- lib/em/callback.rb
|
156
|
+
- lib/em/channel.rb
|
157
|
+
- lib/em/completion.rb
|
158
|
+
- lib/em/connection.rb
|
159
|
+
- lib/em/deferrable.rb
|
160
|
+
- lib/em/deferrable/pool.rb
|
161
|
+
- lib/em/file_watch.rb
|
162
|
+
- lib/em/future.rb
|
163
|
+
- lib/em/io_streamer.rb
|
164
|
+
- lib/em/iterator.rb
|
165
|
+
- lib/em/messages.rb
|
166
|
+
- lib/em/pool.rb
|
167
|
+
- lib/em/process_watch.rb
|
168
|
+
- lib/em/processes.rb
|
169
|
+
- lib/em/protocols.rb
|
170
|
+
- lib/em/protocols/header_and_content.rb
|
171
|
+
- lib/em/protocols/httpclient.rb
|
172
|
+
- lib/em/protocols/httpclient2.rb
|
173
|
+
- lib/em/protocols/line_and_text.rb
|
174
|
+
- lib/em/protocols/line_protocol.rb
|
175
|
+
- lib/em/protocols/linetext2.rb
|
176
|
+
- lib/em/protocols/memcache.rb
|
177
|
+
- lib/em/protocols/object_protocol.rb
|
178
|
+
- lib/em/protocols/postgres3.rb
|
179
|
+
- lib/em/protocols/saslauth.rb
|
180
|
+
- lib/em/protocols/smtpclient.rb
|
181
|
+
- lib/em/protocols/smtpserver.rb
|
182
|
+
- lib/em/protocols/socks4.rb
|
183
|
+
- lib/em/protocols/stomp.rb
|
184
|
+
- lib/em/protocols/tcptest.rb
|
185
|
+
- lib/em/pure_ruby.rb
|
186
|
+
- lib/em/queue.rb
|
187
|
+
- lib/em/resolver.rb
|
188
|
+
- lib/em/spawnable.rb
|
189
|
+
- lib/em/streamer.rb
|
190
|
+
- lib/em/threaded_resource.rb
|
191
|
+
- lib/em/tick_loop.rb
|
192
|
+
- lib/em/timers.rb
|
193
|
+
- lib/em/version.rb
|
194
|
+
- lib/eventmachine.rb
|
195
|
+
- lib/jeventmachine.rb
|
196
|
+
- rakelib/package.rake
|
197
|
+
- rakelib/test.rake
|
198
|
+
- rakelib/test_pure.rake
|
199
|
+
- tests/client.crt
|
200
|
+
- tests/client.key
|
201
|
+
- tests/dhparam.pem
|
202
|
+
- tests/em_ssl_handlers.rb
|
203
|
+
- tests/em_test_helper.rb
|
204
|
+
- tests/jruby/test_jeventmachine.rb
|
205
|
+
- tests/test_attach.rb
|
206
|
+
- tests/test_basic.rb
|
207
|
+
- tests/test_channel.rb
|
208
|
+
- tests/test_completion.rb
|
209
|
+
- tests/test_connection_count.rb
|
210
|
+
- tests/test_connection_write.rb
|
211
|
+
- tests/test_defer.rb
|
212
|
+
- tests/test_deferrable.rb
|
213
|
+
- tests/test_epoll.rb
|
214
|
+
- tests/test_error_handler.rb
|
215
|
+
- tests/test_exc.rb
|
216
|
+
- tests/test_file_watch.rb
|
217
|
+
- tests/test_fork.rb
|
218
|
+
- tests/test_futures.rb
|
219
|
+
- tests/test_handler_check.rb
|
220
|
+
- tests/test_hc.rb
|
221
|
+
- tests/test_httpclient.rb
|
222
|
+
- tests/test_httpclient2.rb
|
223
|
+
- tests/test_idle_connection.rb
|
224
|
+
- tests/test_inactivity_timeout.rb
|
225
|
+
- tests/test_io_streamer.rb
|
226
|
+
- tests/test_ipv4.rb
|
227
|
+
- tests/test_ipv6.rb
|
228
|
+
- tests/test_iterator.rb
|
229
|
+
- tests/test_kb.rb
|
230
|
+
- tests/test_keepalive.rb
|
231
|
+
- tests/test_line_protocol.rb
|
232
|
+
- tests/test_ltp.rb
|
233
|
+
- tests/test_ltp2.rb
|
234
|
+
- tests/test_many_fds.rb
|
235
|
+
- tests/test_next_tick.rb
|
236
|
+
- tests/test_object_protocol.rb
|
237
|
+
- tests/test_pause.rb
|
238
|
+
- tests/test_pending_connect_timeout.rb
|
239
|
+
- tests/test_pool.rb
|
240
|
+
- tests/test_process_watch.rb
|
241
|
+
- tests/test_processes.rb
|
242
|
+
- tests/test_proxy_connection.rb
|
243
|
+
- tests/test_pure.rb
|
244
|
+
- tests/test_queue.rb
|
245
|
+
- tests/test_resolver.rb
|
246
|
+
- tests/test_running.rb
|
247
|
+
- tests/test_sasl.rb
|
248
|
+
- tests/test_send_file.rb
|
249
|
+
- tests/test_servers.rb
|
250
|
+
- tests/test_shutdown_hooks.rb
|
251
|
+
- tests/test_smtpclient.rb
|
252
|
+
- tests/test_smtpserver.rb
|
253
|
+
- tests/test_sock_opt.rb
|
254
|
+
- tests/test_spawn.rb
|
255
|
+
- tests/test_ssl_args.rb
|
256
|
+
- tests/test_ssl_dhparam.rb
|
257
|
+
- tests/test_ssl_ecdh_curve.rb
|
258
|
+
- tests/test_ssl_extensions.rb
|
259
|
+
- tests/test_ssl_methods.rb
|
260
|
+
- tests/test_ssl_protocols.rb
|
261
|
+
- tests/test_ssl_verify.rb
|
262
|
+
- tests/test_stomp.rb
|
263
|
+
- tests/test_system.rb
|
264
|
+
- tests/test_threaded_resource.rb
|
265
|
+
- tests/test_tick_loop.rb
|
266
|
+
- tests/test_timers.rb
|
267
|
+
- tests/test_ud.rb
|
268
|
+
- tests/test_unbind_reason.rb
|
269
|
+
homepage: https://github.com/eventmachine/eventmachine
|
270
|
+
licenses:
|
271
|
+
- Ruby
|
272
|
+
- GPL-2.0
|
273
|
+
metadata: {}
|
274
|
+
post_install_message:
|
275
|
+
rdoc_options:
|
276
|
+
- "--title"
|
277
|
+
- EventMachine
|
278
|
+
- "--main"
|
279
|
+
- README.md
|
280
|
+
- "-x"
|
281
|
+
- lib/em/version
|
282
|
+
- "-x"
|
283
|
+
- lib/jeventmachine
|
284
|
+
require_paths:
|
285
|
+
- lib
|
286
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
287
|
+
requirements:
|
288
|
+
- - ">="
|
289
|
+
- !ruby/object:Gem::Version
|
290
|
+
version: 2.0.0
|
291
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
292
|
+
requirements:
|
293
|
+
- - ">"
|
294
|
+
- !ruby/object:Gem::Version
|
295
|
+
version: 1.3.1
|
296
|
+
requirements: []
|
297
|
+
rubygems_version: 3.2.3
|
298
|
+
signing_key:
|
299
|
+
specification_version: 4
|
300
|
+
summary: Ruby/EventMachine library
|
301
|
+
test_files:
|
302
|
+
- examples/guides/getting_started/01_eventmachine_echo_server.rb
|
303
|
+
- examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb
|
304
|
+
- examples/guides/getting_started/03_simple_chat_server.rb
|
305
|
+
- examples/guides/getting_started/04_simple_chat_server_step_one.rb
|
306
|
+
- examples/guides/getting_started/05_simple_chat_server_step_two.rb
|
307
|
+
- examples/guides/getting_started/06_simple_chat_server_step_three.rb
|
308
|
+
- examples/guides/getting_started/07_simple_chat_server_step_four.rb
|
309
|
+
- examples/guides/getting_started/08_simple_chat_server_step_five.rb
|
310
|
+
- examples/old/ex_channel.rb
|
311
|
+
- examples/old/ex_queue.rb
|
312
|
+
- examples/old/ex_tick_loop_array.rb
|
313
|
+
- examples/old/ex_tick_loop_counter.rb
|
314
|
+
- examples/old/helper.rb
|
315
|
+
- tests/client.crt
|
316
|
+
- tests/client.key
|
317
|
+
- tests/dhparam.pem
|
318
|
+
- tests/em_ssl_handlers.rb
|
319
|
+
- tests/em_test_helper.rb
|
320
|
+
- tests/jruby/test_jeventmachine.rb
|
321
|
+
- tests/test_attach.rb
|
322
|
+
- tests/test_basic.rb
|
323
|
+
- tests/test_channel.rb
|
324
|
+
- tests/test_completion.rb
|
325
|
+
- tests/test_connection_count.rb
|
326
|
+
- tests/test_connection_write.rb
|
327
|
+
- tests/test_defer.rb
|
328
|
+
- tests/test_deferrable.rb
|
329
|
+
- tests/test_epoll.rb
|
330
|
+
- tests/test_error_handler.rb
|
331
|
+
- tests/test_exc.rb
|
332
|
+
- tests/test_file_watch.rb
|
333
|
+
- tests/test_fork.rb
|
334
|
+
- tests/test_futures.rb
|
335
|
+
- tests/test_handler_check.rb
|
336
|
+
- tests/test_hc.rb
|
337
|
+
- tests/test_httpclient.rb
|
338
|
+
- tests/test_httpclient2.rb
|
339
|
+
- tests/test_idle_connection.rb
|
340
|
+
- tests/test_inactivity_timeout.rb
|
341
|
+
- tests/test_io_streamer.rb
|
342
|
+
- tests/test_ipv4.rb
|
343
|
+
- tests/test_ipv6.rb
|
344
|
+
- tests/test_iterator.rb
|
345
|
+
- tests/test_kb.rb
|
346
|
+
- tests/test_keepalive.rb
|
347
|
+
- tests/test_line_protocol.rb
|
348
|
+
- tests/test_ltp.rb
|
349
|
+
- tests/test_ltp2.rb
|
350
|
+
- tests/test_many_fds.rb
|
351
|
+
- tests/test_next_tick.rb
|
352
|
+
- tests/test_object_protocol.rb
|
353
|
+
- tests/test_pause.rb
|
354
|
+
- tests/test_pending_connect_timeout.rb
|
355
|
+
- tests/test_pool.rb
|
356
|
+
- tests/test_process_watch.rb
|
357
|
+
- tests/test_processes.rb
|
358
|
+
- tests/test_proxy_connection.rb
|
359
|
+
- tests/test_pure.rb
|
360
|
+
- tests/test_queue.rb
|
361
|
+
- tests/test_resolver.rb
|
362
|
+
- tests/test_running.rb
|
363
|
+
- tests/test_sasl.rb
|
364
|
+
- tests/test_send_file.rb
|
365
|
+
- tests/test_servers.rb
|
366
|
+
- tests/test_shutdown_hooks.rb
|
367
|
+
- tests/test_smtpclient.rb
|
368
|
+
- tests/test_smtpserver.rb
|
369
|
+
- tests/test_sock_opt.rb
|
370
|
+
- tests/test_spawn.rb
|
371
|
+
- tests/test_ssl_args.rb
|
372
|
+
- tests/test_ssl_dhparam.rb
|
373
|
+
- tests/test_ssl_ecdh_curve.rb
|
374
|
+
- tests/test_ssl_extensions.rb
|
375
|
+
- tests/test_ssl_methods.rb
|
376
|
+
- tests/test_ssl_protocols.rb
|
377
|
+
- tests/test_ssl_verify.rb
|
378
|
+
- tests/test_stomp.rb
|
379
|
+
- tests/test_system.rb
|
380
|
+
- tests/test_threaded_resource.rb
|
381
|
+
- tests/test_tick_loop.rb
|
382
|
+
- tests/test_timers.rb
|
383
|
+
- tests/test_ud.rb
|
384
|
+
- tests/test_unbind_reason.rb
|