eventmachine 0.12.8-x86-mswin32-60 → 0.12.10-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -13
- data/Rakefile +374 -264
- data/eventmachine.gemspec +4 -5
- data/ext/binder.cpp +125 -126
- data/ext/binder.h +46 -48
- data/ext/cmain.cpp +184 -42
- data/ext/cplusplus.cpp +202 -202
- data/ext/ed.cpp +242 -81
- data/ext/ed.h +39 -22
- data/ext/em.cpp +127 -108
- data/ext/em.h +27 -18
- data/ext/emwin.cpp +3 -3
- data/ext/eventmachine.h +49 -38
- data/ext/eventmachine_cpp.h +96 -96
- data/ext/extconf.rb +147 -132
- data/ext/fastfilereader/extconf.rb +82 -76
- data/ext/project.h +151 -140
- data/ext/rubymain.cpp +222 -103
- data/ext/ssl.cpp +460 -460
- data/ext/ssl.h +94 -94
- data/java/src/com/rubyeventmachine/EmReactor.java +570 -423
- data/java/src/com/rubyeventmachine/EventableChannel.java +69 -57
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -171
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -244
- data/java/src/com/rubyeventmachine/{Application.java → application/Application.java} +194 -200
- data/java/src/com/rubyeventmachine/{Connection.java → application/Connection.java} +74 -74
- data/java/src/com/rubyeventmachine/{ConnectionFactory.java → application/ConnectionFactory.java} +36 -36
- data/java/src/com/rubyeventmachine/{DefaultConnectionFactory.java → application/DefaultConnectionFactory.java} +46 -46
- data/java/src/com/rubyeventmachine/{PeriodicTimer.java → application/PeriodicTimer.java} +38 -38
- data/java/src/com/rubyeventmachine/{Timer.java → application/Timer.java} +54 -54
- data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +109 -108
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +148 -146
- data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -53
- data/java/src/com/rubyeventmachine/tests/TestServers.java +75 -74
- data/java/src/com/rubyeventmachine/tests/TestTimers.java +90 -89
- data/lib/em/connection.rb +71 -12
- data/lib/em/deferrable.rb +191 -186
- data/lib/em/protocols.rb +36 -35
- data/lib/em/protocols/httpclient2.rb +590 -582
- data/lib/em/protocols/line_and_text.rb +125 -126
- data/lib/em/protocols/linetext2.rb +161 -160
- data/lib/em/protocols/object_protocol.rb +45 -39
- data/lib/em/protocols/smtpclient.rb +357 -331
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/queue.rb +60 -60
- data/lib/em/timers.rb +56 -55
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +125 -169
- data/lib/jeventmachine.rb +257 -142
- data/tasks/{cpp.rake → cpp.rake_example} +76 -76
- data/tests/test_attach.rb +125 -100
- data/tests/test_basic.rb +1 -2
- data/tests/test_connection_count.rb +34 -44
- data/tests/test_epoll.rb +0 -2
- data/tests/test_get_sock_opt.rb +30 -0
- data/tests/test_httpclient2.rb +3 -3
- data/tests/test_inactivity_timeout.rb +21 -1
- data/tests/test_ltp.rb +182 -188
- data/tests/test_next_tick.rb +0 -2
- data/tests/test_pause.rb +70 -0
- data/tests/test_pending_connect_timeout.rb +48 -0
- data/tests/test_ssl_args.rb +78 -67
- data/tests/test_timers.rb +162 -141
- metadata +13 -11
- data/tasks/project.rake +0 -79
- data/tasks/tests.rake +0 -193
@@ -1,146 +1,148 @@
|
|
1
|
-
/**
|
2
|
-
* $Id$
|
3
|
-
*
|
4
|
-
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
-
* Homepage:: http://rubyeventmachine.com
|
6
|
-
* Date:: 15 Jul 2007
|
7
|
-
*
|
8
|
-
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
-
* usage examples.
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*----------------------------------------------------------------------------
|
13
|
-
*
|
14
|
-
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
-
* Gmail: blackhedd
|
16
|
-
*
|
17
|
-
* This program is free software; you can redistribute it and/or modify
|
18
|
-
* it under the terms of either: 1) the GNU General Public License
|
19
|
-
* as published by the Free Software Foundation; either version 2 of the
|
20
|
-
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
-
*
|
22
|
-
* See the file COPYING for complete licensing information.
|
23
|
-
*
|
24
|
-
*---------------------------------------------------------------------------
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
|
29
|
-
|
30
|
-
package com.rubyeventmachine.tests;
|
31
|
-
|
32
|
-
|
33
|
-
import org.junit.After;
|
34
|
-
import org.junit.AfterClass;
|
35
|
-
import org.junit.Before;
|
36
|
-
import org.junit.BeforeClass;
|
37
|
-
import org.junit.Test;
|
38
|
-
import java.
|
39
|
-
import java.
|
40
|
-
import java.nio
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
1
|
+
/**
|
2
|
+
* $Id$
|
3
|
+
*
|
4
|
+
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
+
* Homepage:: http://rubyeventmachine.com
|
6
|
+
* Date:: 15 Jul 2007
|
7
|
+
*
|
8
|
+
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
+
* usage examples.
|
10
|
+
*
|
11
|
+
*
|
12
|
+
*----------------------------------------------------------------------------
|
13
|
+
*
|
14
|
+
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
+
* Gmail: blackhedd
|
16
|
+
*
|
17
|
+
* This program is free software; you can redistribute it and/or modify
|
18
|
+
* it under the terms of either: 1) the GNU General Public License
|
19
|
+
* as published by the Free Software Foundation; either version 2 of the
|
20
|
+
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
+
*
|
22
|
+
* See the file COPYING for complete licensing information.
|
23
|
+
*
|
24
|
+
*---------------------------------------------------------------------------
|
25
|
+
*
|
26
|
+
*
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
30
|
+
package com.rubyeventmachine.tests;
|
31
|
+
|
32
|
+
|
33
|
+
import org.junit.After;
|
34
|
+
import org.junit.AfterClass;
|
35
|
+
import org.junit.Before;
|
36
|
+
import org.junit.BeforeClass;
|
37
|
+
import org.junit.Test;
|
38
|
+
import java.net.*;
|
39
|
+
import java.io.*;
|
40
|
+
import java.nio.*;
|
41
|
+
import java.nio.channels.*;
|
42
|
+
|
43
|
+
import com.rubyeventmachine.*;
|
44
|
+
import com.rubyeventmachine.application.*;
|
45
|
+
|
46
|
+
public class ConnectTest {
|
47
|
+
|
48
|
+
@BeforeClass
|
49
|
+
public static void setUpBeforeClass() throws Exception {
|
50
|
+
}
|
51
|
+
|
52
|
+
@AfterClass
|
53
|
+
public static void tearDownAfterClass() throws Exception {
|
54
|
+
}
|
55
|
+
|
56
|
+
@Before
|
57
|
+
public void setUp() throws Exception {
|
58
|
+
}
|
59
|
+
|
60
|
+
@After
|
61
|
+
public void tearDown() throws Exception {
|
62
|
+
}
|
63
|
+
|
64
|
+
@Test
|
65
|
+
public final void test1() throws IOException, ClosedChannelException {
|
66
|
+
Application a = new Application();
|
67
|
+
a.addTimer(0, new Timer() {
|
68
|
+
public void fire() {
|
69
|
+
application.connect("www.bayshorenetworks.com", 80, new Connection() {
|
70
|
+
public void connectionCompleted() {
|
71
|
+
close();
|
72
|
+
}
|
73
|
+
public void unbind() {
|
74
|
+
application.stop();
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
});
|
79
|
+
a.run();
|
80
|
+
}
|
81
|
+
|
82
|
+
@Test
|
83
|
+
public final void test2() throws IOException {
|
84
|
+
class Bays extends Connection {
|
85
|
+
public void connectionCompleted() {
|
86
|
+
sendData (ByteBuffer.wrap( new String ("GET / HTTP/1.1\r\nHost: _\r\n\r\n").getBytes()));
|
87
|
+
}
|
88
|
+
public void receiveData (ByteBuffer b) {
|
89
|
+
System.out.println (new String(b.array()));
|
90
|
+
application.stop();
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
Application a = new Application();
|
95
|
+
a.addTimer(0, new Timer() {
|
96
|
+
public void fire() {
|
97
|
+
application.connect("www.bayshorenetworks.com", 80, new Bays());
|
98
|
+
}
|
99
|
+
});
|
100
|
+
a.run();
|
101
|
+
}
|
102
|
+
|
103
|
+
public final void testBindConnect() throws IOException {
|
104
|
+
class Server extends Connection {
|
105
|
+
public void postInit() {
|
106
|
+
// TODO: get peername here and check if the port is 33333
|
107
|
+
// doesnt seem like peername is impl yet?
|
108
|
+
System.out.println("post init!");
|
109
|
+
}
|
110
|
+
};
|
111
|
+
|
112
|
+
Application a = new Application();
|
113
|
+
a.addTimer(0, new Timer() {
|
114
|
+
public void fire() {
|
115
|
+
application.startServer(new InetSocketAddress("localhost", 20000), new DefaultConnectionFactory());
|
116
|
+
}
|
117
|
+
});
|
118
|
+
a.addTimer(500, new Timer() {
|
119
|
+
public void fire() {
|
120
|
+
application.bindConnect("localhost", 33333, "localhost", 20000, new Connection());
|
121
|
+
}
|
122
|
+
});
|
123
|
+
|
124
|
+
a.run();
|
125
|
+
}
|
126
|
+
|
127
|
+
class C1 extends Connection {
|
128
|
+
Application application;
|
129
|
+
public C1 (Application a) {
|
130
|
+
application = a;
|
131
|
+
}
|
132
|
+
public void postInit() {
|
133
|
+
application.stop();
|
134
|
+
}
|
135
|
+
}
|
136
|
+
@Test
|
137
|
+
public final void test3() {
|
138
|
+
final Application a = new Application();
|
139
|
+
a.run (new Runnable() {
|
140
|
+
public void run() {
|
141
|
+
a.connect("www.bayshorenetworks.com", 80, new C1(a));
|
142
|
+
}
|
143
|
+
});
|
144
|
+
}
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
}
|
@@ -1,53 +1,53 @@
|
|
1
|
-
package com.rubyeventmachine.tests;
|
2
|
-
|
3
|
-
import com.rubyeventmachine.*;
|
4
|
-
import java.net.*;
|
5
|
-
import java.nio.*;
|
6
|
-
|
7
|
-
import org.junit.After;
|
8
|
-
import org.junit.AfterClass;
|
9
|
-
import org.junit.Before;
|
10
|
-
import org.junit.BeforeClass;
|
11
|
-
import org.junit.Test;
|
12
|
-
|
13
|
-
|
14
|
-
public class TestDatagrams {
|
15
|
-
|
16
|
-
@BeforeClass
|
17
|
-
public static void setUpBeforeClass() throws Exception {
|
18
|
-
}
|
19
|
-
|
20
|
-
@AfterClass
|
21
|
-
public static void tearDownAfterClass() throws Exception {
|
22
|
-
}
|
23
|
-
|
24
|
-
@Before
|
25
|
-
public void setUp() throws Exception {
|
26
|
-
}
|
27
|
-
|
28
|
-
@After
|
29
|
-
public void tearDown() throws Exception {
|
30
|
-
}
|
31
|
-
|
32
|
-
class A extends Connection {
|
33
|
-
public void receiveData (ByteBuffer bb) {
|
34
|
-
application.stop();
|
35
|
-
}
|
36
|
-
}
|
37
|
-
class B extends Connection {
|
38
|
-
public void postInit() {
|
39
|
-
this.sendDatagram(ByteBuffer.wrap(new String("ABC").getBytes()), new InetSocketAddress ("127.0.0.1", 9550));
|
40
|
-
}
|
41
|
-
|
42
|
-
}
|
43
|
-
@Test
|
44
|
-
public final void testA() {
|
45
|
-
final Application a = new Application();
|
46
|
-
a.run (new Runnable() {
|
47
|
-
public void run() {
|
48
|
-
a.openDatagramSocket( new InetSocketAddress ("0.0.0.0", 9550), new A() );
|
49
|
-
a.openDatagramSocket( new B() );
|
50
|
-
}
|
51
|
-
});
|
52
|
-
}
|
53
|
-
}
|
1
|
+
package com.rubyeventmachine.tests;
|
2
|
+
|
3
|
+
import com.rubyeventmachine.application.*;
|
4
|
+
import java.net.*;
|
5
|
+
import java.nio.*;
|
6
|
+
|
7
|
+
import org.junit.After;
|
8
|
+
import org.junit.AfterClass;
|
9
|
+
import org.junit.Before;
|
10
|
+
import org.junit.BeforeClass;
|
11
|
+
import org.junit.Test;
|
12
|
+
|
13
|
+
|
14
|
+
public class TestDatagrams {
|
15
|
+
|
16
|
+
@BeforeClass
|
17
|
+
public static void setUpBeforeClass() throws Exception {
|
18
|
+
}
|
19
|
+
|
20
|
+
@AfterClass
|
21
|
+
public static void tearDownAfterClass() throws Exception {
|
22
|
+
}
|
23
|
+
|
24
|
+
@Before
|
25
|
+
public void setUp() throws Exception {
|
26
|
+
}
|
27
|
+
|
28
|
+
@After
|
29
|
+
public void tearDown() throws Exception {
|
30
|
+
}
|
31
|
+
|
32
|
+
class A extends Connection {
|
33
|
+
public void receiveData (ByteBuffer bb) {
|
34
|
+
application.stop();
|
35
|
+
}
|
36
|
+
}
|
37
|
+
class B extends Connection {
|
38
|
+
public void postInit() {
|
39
|
+
this.sendDatagram(ByteBuffer.wrap(new String("ABC").getBytes()), new InetSocketAddress ("127.0.0.1", 9550));
|
40
|
+
}
|
41
|
+
|
42
|
+
}
|
43
|
+
@Test
|
44
|
+
public final void testA() {
|
45
|
+
final Application a = new Application();
|
46
|
+
a.run (new Runnable() {
|
47
|
+
public void run() {
|
48
|
+
a.openDatagramSocket( new InetSocketAddress ("0.0.0.0", 9550), new A() );
|
49
|
+
a.openDatagramSocket( new B() );
|
50
|
+
}
|
51
|
+
});
|
52
|
+
}
|
53
|
+
}
|
@@ -1,74 +1,75 @@
|
|
1
|
-
/**
|
2
|
-
* $Id$
|
3
|
-
*
|
4
|
-
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
-
* Homepage:: http://rubyeventmachine.com
|
6
|
-
* Date:: 15 Jul 2007
|
7
|
-
*
|
8
|
-
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
-
* usage examples.
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*----------------------------------------------------------------------------
|
13
|
-
*
|
14
|
-
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
-
* Gmail: blackhedd
|
16
|
-
*
|
17
|
-
* This program is free software; you can redistribute it and/or modify
|
18
|
-
* it under the terms of either: 1) the GNU General Public License
|
19
|
-
* as published by the Free Software Foundation; either version 2 of the
|
20
|
-
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
-
*
|
22
|
-
* See the file COPYING for complete licensing information.
|
23
|
-
*
|
24
|
-
*---------------------------------------------------------------------------
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
|
29
|
-
|
30
|
-
package com.rubyeventmachine.tests;
|
31
|
-
|
32
|
-
|
33
|
-
import com.rubyeventmachine.*;
|
34
|
-
import
|
35
|
-
import
|
36
|
-
import org.junit.
|
37
|
-
import org.junit.
|
38
|
-
import org.junit.
|
39
|
-
import org.junit.
|
40
|
-
import org.junit.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
a
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
1
|
+
/**
|
2
|
+
* $Id$
|
3
|
+
*
|
4
|
+
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
+
* Homepage:: http://rubyeventmachine.com
|
6
|
+
* Date:: 15 Jul 2007
|
7
|
+
*
|
8
|
+
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
+
* usage examples.
|
10
|
+
*
|
11
|
+
*
|
12
|
+
*----------------------------------------------------------------------------
|
13
|
+
*
|
14
|
+
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
+
* Gmail: blackhedd
|
16
|
+
*
|
17
|
+
* This program is free software; you can redistribute it and/or modify
|
18
|
+
* it under the terms of either: 1) the GNU General Public License
|
19
|
+
* as published by the Free Software Foundation; either version 2 of the
|
20
|
+
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
+
*
|
22
|
+
* See the file COPYING for complete licensing information.
|
23
|
+
*
|
24
|
+
*---------------------------------------------------------------------------
|
25
|
+
*
|
26
|
+
*
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
30
|
+
package com.rubyeventmachine.tests;
|
31
|
+
|
32
|
+
|
33
|
+
import com.rubyeventmachine.*;
|
34
|
+
import com.rubyeventmachine.application.*;
|
35
|
+
import java.net.*;
|
36
|
+
import org.junit.After;
|
37
|
+
import org.junit.AfterClass;
|
38
|
+
import org.junit.Before;
|
39
|
+
import org.junit.BeforeClass;
|
40
|
+
import org.junit.Test;
|
41
|
+
import org.junit.Assert;
|
42
|
+
|
43
|
+
public class TestServers {
|
44
|
+
|
45
|
+
@BeforeClass
|
46
|
+
public static void setUpBeforeClass() throws Exception {
|
47
|
+
}
|
48
|
+
|
49
|
+
@AfterClass
|
50
|
+
public static void tearDownAfterClass() throws Exception {
|
51
|
+
}
|
52
|
+
|
53
|
+
@Before
|
54
|
+
public void setUp() throws Exception {
|
55
|
+
}
|
56
|
+
|
57
|
+
@After
|
58
|
+
public void tearDown() throws Exception {
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
@Test
|
63
|
+
public void testBadServerAddress() {
|
64
|
+
final Application a = new Application();
|
65
|
+
a.run (new Runnable() {
|
66
|
+
public void run() {
|
67
|
+
try {
|
68
|
+
a.startServer(new InetSocketAddress ("100.100.100.100", 100), new DefaultConnectionFactory());
|
69
|
+
Assert.fail ("was supposed to throw a reactor exception");
|
70
|
+
} catch (EmReactorException e) {}
|
71
|
+
a.stop();
|
72
|
+
}
|
73
|
+
});
|
74
|
+
}
|
75
|
+
}
|