forked from kb18519142009/android_interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtcp.js
More file actions
35 lines (31 loc) · 947 Bytes
/
tcp.js
File metadata and controls
35 lines (31 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var dnode = require('../../')
var test = require('tape');
var util = require('util');
test('simple', function (t) {
t.plan(3);
var port = Math.floor(Math.random() * 40000 + 10000);
var server = dnode({
timesTen : function (n,reply) {
t.equal(n.number, 5);
reply(n.number * 10);
},
print : function (n,reply) {
reply(util.inspect(n));
},
}).listen(port);
server.on('listening', function () {
dnode.connect(port, function (remote, conn) {
t.equal(conn.stream.remoteAddress, '127.0.0.1');
var args = {
number : 5,
func : function () {},
};
remote.timesTen(args, function (m) {
t.equal(m, 50, '5 * 10 == 50');
conn.end();
server.close();
t.end();
});
});
});
});