Socket
Socket
Sign inDemoInstall

thread.js

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

benchmark/b.sh

47

examples/client_cc.js

@@ -8,36 +8,37 @@ var net = require("net");

conn.on('data', function(data) {
conn.on('data', ondata);
conn.on('end', onend);
net.createConnection("127.0.0.1", 80, function(sock) {
sock.on('data', function(innerdata) {
sock.close();
sock = null;
};
// var str = 'Hello World ' + new Date().toLocaleString() + '\r\n' +
// buf;
var str = 'Hello World\r\n' + innerdata;
var header = 'HTTP/1.1 200 OK\r\n';
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
conn.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
conn.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
});
function ondata(data) {
var self = this;
net.createConnection("127.0.0.1", 80, function(sock) {
sock.on('data', function(innerdata) {
sock.close();
sock = null;
sock.on('end', function(innerdata) {
var str = 'Hello World\r\n' + innerdata;
var header = 'HTTP/1.1 200 OK\r\n';
});
sock.write('GET / HTTP/1.0\r\n\r\n');
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
self.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
self.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
});
});
conn.on('end', function(data) {
sock.on('end', function(innerdata) {
});
sock.write('GET / HTTP/1.0\r\n\r\n');
});
};
};
function onend() {
}

@@ -8,18 +8,21 @@ var net = require("net");

conn.on('data', function(data) {
var str = 'Hello World';
var header = 'HTTP/1.1 200 OK\r\n';
conn.on('data', ondata);
conn.on('end', onend);
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
conn.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
conn.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
});
};
conn.on('end', function(data) {
});
function ondata(data) {
var str = 'Hello World';
var header = 'HTTP/1.1 200 OK\r\n';
};
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
this.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
this.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
}
function onend() {
}

@@ -12,3 +12,3 @@ var http = require('thread.js').http;

wtrTimeout : 15,
backlogSize : 5000,
backlogSize : 3000,
};

@@ -19,15 +19,10 @@

http.createServer(opt, function(req, res) {
// console.log(req.getHeader('Host'));
// var str = 'hello world ' + new Date().toGMTString() + ' from ip:' + req.ip
// + ':' + req.port;
http.createServer(opt, onconnect).listen(process.argv[3] || 8080);
function onconnect(req, res) {
var str = 'hello world';
// res.writeHead(200, {
// 'Content-Type' : 'text/html; charset=utf8',
// 'Content-Length' : calcCharLength(str),
// });
res.addHeader('Content-Type', 'text/html');
res.addHeader('Content-Length', calcCharLength(str));
res.endHTML(str);
}).listen(process.argv[3] || 8080);
}

@@ -5,7 +5,7 @@ var net = require('thread.js').net;

rtransportNum : process.argv[2],
maxEvents : 10000,
maxEvents : 20000,
sysOpenFiles : 1000000,
backlogSize : 5000,
backlogSize : 3000,
};
net.createServer(opt).registerFile('./client.js').listen(process.argv[3] || 8080);

@@ -11,7 +11,28 @@ var net = require('thread.js').net;

var keepAliveRe = /Connection: keep-alive/i;
net.createServer(opt, function(conn) {
net.createServer(opt, onconnect).registerScript(simpleHttpKeepAlive).listen(process.argv[3] || 8080);
}).registerScript(simpleHttpKeepAlive).listen(process.argv[3] || 8080);
function onconnect(conn) {
// in case the request pass back to main loop
conn.on('data', ondata);
conn.on('end', onend);
}
function ondata(data) {
var str = 'Hello World';
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
this.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
this.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
}
function onend() {
}
function simpleHttpKeepAlive(reqtext, fd, evo) {

@@ -18,0 +39,0 @@ if (reqtext.substring(reqtext.length - 4) !== '\r\n\r\n') {

@@ -7,29 +7,37 @@ var net = require('thread.js').net;

rtransportNum : process.argv[2],
maxEvents : 10000,
maxEvents : 20000,
sysOpenFiles : 1000000,
backlogSize : 5000,
backlogSize : 3000,
requestTimeout : 5,
};
var keepAliveRe = /Connection: keep-alive/i;
net.createServer(opt, function(conn) {
net.createServer(opt, onconnect).listen(process.argv[3] || 8080);
conn.on('data', function(data) {
// var str = 'Hello World ' + conn.fd + ' ' + conn.port + ' ' + conn.ip + '
// ' + conn.bytesRead + ' ' + conn.bytesWrite;
var str = 'Hello World';
var header = 'HTTP/1.1 200 OK\r\n';
function onconnect(conn) {
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
conn.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
conn.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
});
conn.on('data', ondata);
conn.on('end', onend);
}
conn.on('end', function() {
});
}).listen(process.argv[3] || 8080);
function ondata(data) {
// var str = 'Hello World ' + conn.fd + ' ' + conn.port + ' ' + conn.ip + '
// ' + conn.bytesRead + ' ' + conn.bytesWrite;
var str = 'Hello World';
var header = 'HTTP/1.1 200 OK\r\n';
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
this.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
this.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
}
function onend() {
}

@@ -5,29 +5,31 @@ var cluster = require('cluster');

var keepAliveRe = /Connection: keep-alive/i;
var keepAliveRe = /keep-alive/i;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
// Fork workers.
for ( var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
// Workers can share any TCP connection
// In this case its a HTTP server
// Workers can share any TCP connection
// In this case its a HTTP server
http.createServer(function(req, res) {
http.createServer(onconnect).listen(8080);
}
if ( keepAliveRe.test(req.headers['Connection']) ) {
res.writeHead(200);
res.write("hello world\n");
} else {
res.writeHead(200);
res.end("hello world\n");
}
}).listen(8080);
}
function onconnect(req, res) {
if (keepAliveRe.test(req.headers['Connection'])) {
res.writeHead(200, {
Connection : 'keep-alive'
});
res.write("hello world\n");
} else {
res.writeHead(200);
res.end("hello world\n");
}
}

@@ -20,23 +20,27 @@ var cluster = require('cluster');

net.createServer(function(conn) {
net.createServer(onconnect).listen(8080);
}
conn.on('data', function(data) {
var header = 'HTTP/1.1 200 OK\r\n';
var str = 'Hello World';
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
conn.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str)
} else {
conn.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str)
}
function onconnect(conn) {
});
conn.on('data', ondata);
conn.on('end', onend);
conn.on('end', function() {
// console.log('end');
});
}
function ondata(data) {
var header = 'HTTP/1.1 200 OK\r\n';
var str = 'Hello World';
}).listen(8080);
if (keepAliveRe.test(data) === true) {
header += 'Connection: keep-alive\r\n';
this.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
this.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
}
function onend() {
}

@@ -20,3 +20,3 @@ // Copyright(C) 2012 by RobertL

var net_thread = require('../build/Release/net_thread');
var netThread = require('../build/Release/net_thread');
var fs = require('fs');

@@ -34,7 +34,7 @@ var os = require('os');

exclude : true,
exclude : false,
sysOpenFiles : 2500000, // lboundry at 2000
rtransportNum : os.cpus().length,
transportNum : os.cpus().length,
maxEvents : 10000,
dataBusNum : 3500,
// dataBusNum : 200,

@@ -44,4 +44,4 @@ // also need to modify net.core.netdev_max_backlog

rdataBufSize : 8192, // lboundry at 8192, uboundry at 256k
wdataBufSize : 8192, // lboundry at 8192, uboundry at 256k
rdataBufSize : 8192, // lboundry at 256, uboundry at 256k
wdataBufSize : 8192, // lboundry at 256, uboundry at 256k
rdataBufGrowby : 8192, // rdata buffer will grow by this number

@@ -96,3 +96,3 @@ // rdataBufSize beyond this number will emit ondata event instead of growing

var ar = net_thread.createServer(this.ip, options);
var ar = netThread.createServer(this.ip, options);
this.snum = ar[0];

@@ -134,3 +134,3 @@ var evo = ar[1];

this.port = port || 80;
net_thread.listen(this.snum, port || 80, require('os').cpus().length, ip);
netThread.listen(this.snum, port || 80, require('os').cpus().length, ip);
return this;

@@ -140,3 +140,3 @@ };

server.prototype.close = function() {
net_thread.closeServer(this.snum);
netThread.closeServer(this.snum);
this.connections = 0;

@@ -153,3 +153,3 @@

if (typeof val === 'function') {
net_thread.registerScript(this.snum, val.toString());
netThread.registerScript(this.snum, val.toString());
}

@@ -160,4 +160,3 @@ return this;

server.prototype.registerFile = function(val) {
var filecontent = fs.readFileSync(val, 'utf8');
net_thread.registerFile(this.snum, filecontent);
netThread.registerFile(this.snum, val);
return this;

@@ -164,0 +163,0 @@ };

{
"name": "thread.js",
"version": "0.0.1",
"version": "0.0.2",
"main": "index.js",
"description": "A high concurrent IPV4/V6 threading server",
"keywords": [
"v8 multithreading",
"multithreading",
"ipv4",
"ipv6",
"thread"
"v8 multithreading",
"multithreading",
"ipv4",
"ipv6",
"thread"
],
"author": [
"rob333 <rob333.2005@gmail.com> (https://github.com/rob333)"
],
"author": "RobertL",
"homepage": "http://rob333.github.com/thread.js/",

@@ -25,3 +23,3 @@ "bugs": {

"scripts": {
"install": "node-waf configure install"
"install": "node-gyp configure build"
},

@@ -28,0 +26,0 @@ "os": [

Thread.js
=========
Thread.js is a very high concurrent ipv4/v6 server of node.js addon with javascript support base on epoll and pthread.
Thread.js is a very high concurrent ipv4/v6 server of a node.js addon with a subset of common.js.
Please see [support page](http://rob333.github.com/thread.js/) for detail.
Please see [homepage](http://rob333.github.com/thread.js/) for detail.

@@ -11,3 +11,3 @@

+ Multithreading by pthread.
+ Multithreading by pthread with a subset of commonjs implements.
+ Non-blocking I/O base on epoll.

@@ -21,8 +21,10 @@ + Implements a binary event emitter in v8.

Thread.js provides 2+1 methods for application.
Thread.js provides three ways for applications.
1. **Runs javascript with node.js**. See examples/net.js.
2. **Runs javascript on the thread**. See examples/net_regscript.js, examples/net_regfile.js and examples/net_regfile_cc.js.
3. Additionally, thread.js provides a **continuous write mode**. Applications can send data to client at any time and doesn't need to wait for ondrain event . This can be used as a kind of pipelining server.
**Note: Continuous write mode will try to send data all at once. Client applications should take care of the length received.
1. **Run with node.js** - act as a replacement IP layer of node.js. Please see examples/net.js for example.
2. **Run on the thread** - support a subset of commonjs on the thread, currently implements a subset of common.js. Please see examples/net_regfile.js and examples/net_regfile_cc.js for example.
3. **Implement a service handler** - support writting a service handler to implement a protocol, like http, websocket etc. Please see `examples/http.js` and `examples/http_regfile.js` for example.
Additionally, thread.js provides a **continuous write mode**. Applications can send data to client at any time and doesn't need to wait for ondrain event .
**Note: Continuous write mode will try to send data all at once. Application should take care of the length received.

@@ -32,8 +34,9 @@

+ `examples/net.js` - Use thread.js as a network IO worker.(method 1)
+ `examples/http_demo.js` - This example shows a way of doing http service with thread.js. This is temporary file, future version plan to support a setService method of writing user defined protocol.
+ `examples/net_regscript.js` - Register a function to thread, doing simple javascript process. (simple thread.js mode)
+ `examples/net_regfile.js` - Register a file to thread and runs thread.js api. (method 2)
+ `examples/net_regfile_cc.js` - Demostrate createConnection operation on thread.js.
**Todo:** Should improve performance by applying a command/connection queue manager.
+ `examples/net.js` - use thread.js as a network layer.
+ `examples/net_regscript.js` - register a function to thread.js, support doing pure javascript process. (simple thread.js mode)
+ `examples/net_regfile.js`, `examples/client.js` - register a javascript file to thread.js and runs thread.js api in the file.
+ `examples/net_regfile_cc.js`, `examples/client_cc.js` - demostrate using thread.js api of net.createConnection.
**Todo:** improve performance by applying a command/connection queue manager.
+ `examples/http.js` - use thread.js as a network layer and implements a http service handler.
+ `examples/http_regfile.js`, `examples/http_client.js` - register a javascript file to thread.js, runs thread.js api in the file and implements a http service handler.

@@ -56,7 +59,7 @@ <br>

Benchmark is done by using weighttp on an i7 2.67Ghz CPU (4cores) on a Ubuntu 12.04 LTS 64bits server.
Benchmark is done by using weighttp on an i7 2.67Ghz CPU (4cores) on a Ubuntu 12.04 LTS 64-bit server.
######install weighttp
1 First install libev by `apt-get install libev-dev`
1 Install libev by `apt-get install libev-dev`
2 Follow the instruction at [weighttp wiki](http://redmine.lighttpd.net/projects/weighttp/wiki) to install weighttp.

@@ -67,3 +70,3 @@

User should at least set the TCP\_TW\_REUSE, or there is very likely system will failed to connect with 'Cannot assign requested address (99)', see description at [weighttp wiki](http://redmine.lighttpd.net/projects/weighttp/wiki).
User should at least set the TCP\_TW\_REUSE, or there is very likely system will fail to connect with 'Cannot assign requested address (99)', see description at [weighttp wiki](http://redmine.lighttpd.net/projects/weighttp/wiki).

@@ -84,2 +87,3 @@ Here is the list of sysctl settings of `deps/10-web.conf`:

net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 12000

@@ -89,11 +93,10 @@ net.ipv4.tcp_max_tw_buckets = 2000000

net.ipv4.tcp_rmem = 30000000 30000000 30000000
#net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_wmem = 30000000 30000000 30000000
net.ipv4.tcp_orphan_retries = 1
net.ipv4.tcp_fin_timeout = 25
#net.ipv4.tcp_max_orphans = 8192
net.ipv4.tcp_max_orphans = 8192
#net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1

@@ -105,68 +108,120 @@ Note 1: All detail outputs and test scripts can be found at directory `/benchmark`.

#####Performance:
A simple 'hello world' server.
Using:
`examples/node_cluster.js`
`examples/net.js` - tj with node
`examples/net_regscript.js` - simple tj
`examples/net_regfile.js` - tj
All test runs as 8 cpu units.
#####NET Performance:
A 'hello world' server using net module.
+ node with cluster module - `examples/node_cluster.js`
+ node with thread.js - `examples/net.js`
+ thread.js - `examples/net_regfile.js`
ab -n 200000 -c xxxx 127.0.0.1:8080/
200client 1000client 2000client
node_cluster 21001.89 19000.00 18717.28
tj wite node 23792.30 23175.49 22707.17
tj simple 24220.45 23182.52 22709.86
tj 23785.49 22628.42 22562.02
All tests run as 8 cpu units.
ab -n 200000 -c xxxx -k 127.0.0.1:8080/
200client 1000client 2000client
node_cluster 134403.36 136077.29 116258.52
tj wite node 124507.96 109830.13 103300.93
tj simple 124113.37 105600.24 100807.72
tj 125836.74 99274.16 96787.53
net connections/sec
node_cluster node with tj threadjs
200 48352 81343 83121
500 47978 78007 81971
750 40199 77905 76840
1000 47170 73458 78905
1250 41250 72063 76738
1500 44624 73598 74492
1750 40386 72416 75769
2000 35174 73918 75174
![net_conn](http://rob333.github.com/thread.js/images/net_conn.png)
weighttp -n 200000 -c xxxx -t 8 127.0.0.1:8080/
200client 1000client 2000client
node_cluster 48644 41211 43047
tj wite node 78133 76878 72929
tj simple 78061 73478 72209
tj 79698 76232 74941
net keepalive requests/sec
node_cluster node with tj threadjs
200 173069 297282 383607
500 174376 311152 376256
750 177343 315716 374010
1000 178202 296393 365689
1250 174102 283776 345388
1500 174480 276573 336369
1750 171244 266155 319608
2000 170675 267328 313555
weighttp -n 200000 -c xxxx -t 8 -k 127.0.0.1:8080/
200client 1000client 2000client
node_cluster 168867 163490 161464
tj wite node 179399 195751 178095
tj simple 289362 281941 256841
tj 224530 210895 196616
![net_keep](http://rob333.github.com/thread.js/images/net_keep.png)
<br>
#####HTTP Performance:
A 'hello world' server using simple_http service handler.
+ node http with cluster module - `examples/node_cluster_http.js`
+ node with thread.js with a service handler - `examples/http.js`
+ thread.js with a service handler - `examples/http_regfile.js`, `examples/http_client.js`
All tests run as 8 cpu units.
http connections/sec
node_cluster node with tj threadjs
200 31552 82054 81518
500 29468 78882 80104
750 30008 75741 75938
1000 29278 71373 77577
1250 14400 72631 75945
1500 13859 76791 75165
1750 12417 72147 74491
2000 12667 73394 74089
![http_conn](http://rob333.github.com/thread.js/images/http_conn.png)
http keepalive requests/sec
node_cluster node with tj threadjs
200 70151 213382 329009
500 70231 230153 328236
750 71910 223123 329234
1000 58294 216859 321123
1250 69058 212391 307097
1500 69118 210384 298151
1750 66007 205793 287315
2000 69120 203913 279819
![http_keep](http://rob333.github.com/thread.js/images/http_keep.png)
<br>
#####Throughput:
Benchmark by `benchmark/lw.sh`
A 50k response server using method 2 with typedarray.
\>node net_regfile-lw-50k-byte 4
+ use node cluster and node buffer - `test/http_simple_cluster.js`
+ use threadjs and a 50k ArrayBuffer - `test/net_regfile-lw-50k-byte.js`
+ use threadjs and a 100k ArrayBuffer - `test/net_regfile-lw-100k-byte.js`
\>weighttp -n 20000 -c 200 -t 4 -k 127.0.0.1:8080/
finished in 0 sec, 587 millisec and 291 microsec, **34054 req/s, 1704925 kbyte/s**
All tests run as 8 cpu units.
<br>
50k response server
cluster threadjs cluster-keep threadjs-keep
200 948283 1553675 1396788 1954481
500 962058 1455664 1464215 1821893
750 938583 1338557 1399691 1815001
1000 592578 1425235 1432528 1791102
1250 702026 1326193 964106 1743758
1500 597193 1300322 1348425 1704217
1750 793223 1216900 1337272 1713497
2000 548075 1203525 1358335 1642143
A 50k response server using method 1 with typedarray.
\>node net-lw-50k-byte 4
![lw50k](http://rob333.github.com/thread.js/images/lw50k.png)
\>weighttp -n 20000 -c 200 -t 4 -k 127.0.0.1:8080/
finished in 1 sec, 49 millisec and 541 microsec, **19055 req/s, 954024 kbyte/s**
100k response server
cluster threadjs cluster-keep threadjs-keep
200 1618670 2021279 2425676 2261467
500 1622245 1843869 2428176 2199467
750 1615689 1819297 2236474 2134023
1000 1593252 1817217 2337331 2053169
1250 1541604 1670520 2321876 2067337
1500 1570330 1708348 1893426 2071124
1750 656290 1750326 2123765 1965395
2000 1119305 1669303 2180329 1920265
![lw100k](http://rob333.github.com/thread.js/images/lw100k.png)
<br>
#####Stability:
Run node with `--trace_gc --trace_gc_verbose` shows a stable memory allocation rate, can run days without restart the program.
Thread.js reuses and caches most of the javascript objects.
You can see a stable memory allocator by running node with `--trace_gc --trace_gc_verbose` v8 flags.

@@ -176,3 +231,3 @@

API - SUPPORT
API
----------------

@@ -199,5 +254,3 @@ please see at http://rob333.github.com/thread.js/

+ setService( module ).
+ Add timer support in thread.js api.
+ Maybe add metrics operation to typedarray, doing collision detection etc..
+ Add metrics operation to typedarray, doing collision detection etc..
+ Add more common api in thread.js.

@@ -210,7 +263,4 @@

--------------
Pulling and contrubtion is welcome.
You can see `src/jslib/typed_array.cc` for an example on writing thread.js api.
Pulling and contribution is very welcome. Thanks.
There is one big rule: Don't cache object in c/c++ global as normal modules do, instead you can store the object by using Context::GetCurrent()->Global()->SetHiddenValue(), this is due to multi-threading in v8.
<br>

@@ -221,3 +271,3 @@

------------------
+ *08-25-2012* Refactor connection events to be compatiable with node.js.
+ *09-09-2012* v0.0.2: implements service handler and fix bugs.
+ *08-23-2012* v0.0.1: First announce, implements main-loop, regScript, regFile and continuous write mode.

@@ -224,0 +274,0 @@

@@ -6,33 +6,32 @@ var net = require("net");

function onconnect(conn) {
var buf = '';
conn.on('data', function(data) {
buf += data;
});
var b = new emitter();
b.on('abc', function() {
console.log('1')
console.log('1');
});
conn.on('end', function(data) {
b.emit('abc');
conn.on('data', ondata);
conn.on('end', onend);
var a = conn.buffer;
buf += data;
delete a;
var str = 'Hello World ' + conn.fd + ' ' + new Date().toLocaleString();
// var a = conn.ascii;
// var b = conn.unicode;
var keepalive = keepAliveRe.test(buf);
var header = 'HTTP/1.1 200 OK\r\n';
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
conn.wtr(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
conn.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
buf = '';
});
}
};
function ondata(data) {
b.emit('abc');
var a = this.buffer;
a = null;
var str = 'Hello World ' + this.fd + ' ' + new Date().toLocaleString();
var a = this.ascii;
var b = this.unicode;
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
this.write(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
} else {
this.end(header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str);
}
}
function onend() {
}

@@ -15,36 +15,56 @@ var keepAliveRe = /Connection: keep-alive/i;

var buf = '';
conn.on('data', function(data) {
buf += data;
});
conn.on('data', ondata);
conn.on('end', onend);
conn.on('end', function(data) {
buf += data;
// conn.on('data', function(data) {
// var str = 'Hello World';
// var keepalive = keepAliveRe.test(data);
// var header = 'HTTP/1.1 200 OK\r\n';
//
// if (keepalive === true) {
// header += 'Connection: keep-alive\r\n';
// str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
// var dv = prependBuffer(str, AB, headerPreserveSize, -1);
//
// this.write(dv);
//
// } else {
//
// str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
// var dv = prependBuffer(str, AB, headerPreserveSize, -1);
//
// this.end(dv);
// }
// });
//
// conn.on('end', function() {
// });
var str = 'Hello World ' + conn.fd;
// var a = conn.ascii;
// var b = conn.unicode;
var keepalive = keepAliveRe.test(buf);
var header = 'HTTP/1.1 200 OK\r\n';
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
};
conn.write(dv);
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
} else {
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
this.write(dv);
conn.end(dv);
}
} else {
buf = '';
});
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
};
this.end(dv);
}
}
function onend() {
}
function prependBuffer(str, ab, headerPreserveSize) {

@@ -51,0 +71,0 @@ var n = str.length;

var net = require('thread.js').net;
var opt = {
rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
// maxEvents : ,

@@ -10,2 +9,2 @@ sysOpenFiles : 600000,

net.createServer(opt).registerFile('./test/net_regfile-lw-100k-byte-client.js').listen(process.argv[4] || 8080);
net.createServer(opt).registerFile('./test/net_regfile-lw-100k-byte-client.js').listen(process.argv[3] || 8080);

@@ -15,36 +15,56 @@ var keepAliveRe = /Connection: keep-alive/i;

var buf = '';
conn.on('data', function(data) {
buf += data;
});
conn.on('data', ondata);
conn.on('end', onend);
conn.on('end', function(data) {
buf += data;
// conn.on('data', function(data) {
// var str = 'Hello World';
// var keepalive = keepAliveRe.test(data);
// var header = 'HTTP/1.1 200 OK\r\n';
//
// if (keepalive === true) {
// header += 'Connection: keep-alive\r\n';
// str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
// var dv = prependBuffer(str, AB, headerPreserveSize, -1);
//
// this.write(dv);
//
// } else {
//
// str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
// var dv = prependBuffer(str, AB, headerPreserveSize, -1);
//
// this.end(dv);
// }
// });
//
// conn.on('end', function() {
// });
var str = 'Hello World ' + conn.fd;
// var a = conn.ascii;
// var b = conn.unicode;
var keepalive = keepAliveRe.test(buf);
var header = 'HTTP/1.1 200 OK\r\n';
}
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
conn.write(dv);
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
} else {
this.write(dv);
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
} else {
conn.end(dv);
}
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
buf = '';
});
this.end(dv);
}
}
};
function onend() {
}
function prependBuffer(str, ab, headerPreserveSize) {

@@ -51,0 +71,0 @@ var n = str.length;

var net = require('thread.js').net;
var opt = {
rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
// maxEvents : ,

@@ -10,2 +9,2 @@ sysOpenFiles : 600000,

net.createServer(opt).registerFile('./test/net_regfile-lw-50k-byte-client.js').listen(process.argv[4] || 8080);
net.createServer(opt).registerFile('./test/net_regfile-lw-50k-byte-client.js').listen(process.argv[3] || 8080);

@@ -55,35 +55,31 @@ var keepAliveRe = /Connection: keep-alive/i;

var buf = '';
conn.on('data', function(data) {
buf += data;
});
conn.on('data', ondata);
conn.on('end', onend);
conn.on('end', function(data) {
buf += data;
}
var str = 'Hello World ' + conn.fd;
// var a = conn.ascii;
// var b = conn.unicode;
var keepalive = keepAliveRe.test(buf);
var header = 'HTTP/1.1 200 OK\r\n';
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
conn.write(dv);
this.write(dv);
} else {
} else {
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
conn.end(dv);
}
this.end(dv);
}
}
buf = '';
});
function onend() {
}
};

@@ -90,0 +86,0 @@ function prependBuffer(str, ab, headerPreserveSize) {

var net = require('thread.js').net;
var opt = {
rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
// maxEvents : ,

@@ -10,2 +9,2 @@ sysOpenFiles : 600000,

net.createServer(opt).registerFile('./test/net_regfile-test-typedarray-client.js').listen(process.argv[4] || 8080);
net.createServer(opt).registerFile('./test/net_regfile-test-typedarray-client.js').listen(process.argv[3] || 8080);

@@ -6,5 +6,4 @@ var net = require('thread.js').net;

rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
sysOpenFiles : 99999,
backlogSize : 512,
backlogSize : 3000,
};

@@ -22,36 +21,38 @@

var keepAliveRe = /Connection: keep-alive/i;
net.createServer(opt, function(conn) {
var buf = '';
conn.on('data', function(data) {
buf += data;
});
net.createServer(opt, onconnect).listen(process.argv[3] || 8080);
conn.on('end', function(data) {
buf += data;
var str = 'Hello World ' + conn.fd;
var keepalive = keepAliveRe.test(buf);
var header = 'HTTP/1.1 200 OK\r\n';
function onconnect(conn) {
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
conn.on('data', ondata);
conn.on('end', onend);
conn.write(dv);
}
} else {
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
conn.end(dv);
}
this.write(dv);
buf = '';
});
} else {
}).listen(process.argv[4] || 8080);
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
this.end(dv);
}
}
function onend() {
}
function prependBuffer(str, ab, headerPreserveSize) {

@@ -58,0 +59,0 @@ var n = str.length;

@@ -6,5 +6,4 @@ var net = require('thread.js').net;

rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
sysOpenFiles : 99999,
backlogSize : 512,
backlogSize : 3000,
};

@@ -23,30 +22,30 @@

var keepAliveRe = /Connection: keep-alive/i;
net.createServer(opt, function(conn) {
var buf = '';
conn.on('data', function(data) {
buf += data;
});
net.createServer(opt, onconnect).listen(process.argv[3] || 8080);
conn.on('end', function(data) {
buf += data;
function onconnect(conn) {
var str = 'Hello World ' + conn.fd;
var keepalive = keepAliveRe.test(buf);
str = odata;
var header = 'HTTP/1.1 200 OK\r\n';
conn.on('data', ondata);
conn.on('end', onend);
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
}
conn.write(str);
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
str = odata;
var header = 'HTTP/1.1 200 OK\r\n';
} else {
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
conn.end(str);
}
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
buf = '';
});
this.write(str);
}).listen(process.argv[4] || 8080);
} else {
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
this.end(str);
}
}
function onend() {
}

@@ -6,5 +6,4 @@ var net = require('thread.js').net;

rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
sysOpenFiles : 99999,
backlogSize : 512,
backlogSize : 3000,
};

@@ -22,36 +21,39 @@

var keepAliveRe = /Connection: keep-alive/i;
net.createServer(opt, function(conn) {
var buf = '';
conn.on('data', function(data) {
buf += data;
});
conn.on('end', function(data) {
buf += data;
net.createServer(opt, onconnect).listen(process.argv[3] || 8080);
var str = 'Hello World ' + conn.fd;
var keepalive = keepAliveRe.test(buf);
var header = 'HTTP/1.1 200 OK\r\n';
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
function onconnect(conn) {
conn.write(dv);
conn.on('data', ondata);
conn.on('end', onend);
} else {
}
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
conn.end(dv);
}
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
buf = '';
});
this.write(dv);
}).listen(process.argv[4] || 8080);
} else {
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
this.end(dv);
}
}
function onend() {
}
function prependBuffer(str, ab, headerPreserveSize) {

@@ -58,0 +60,0 @@ var n = str.length;

@@ -6,5 +6,4 @@ var net = require('thread.js').net;

rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
sysOpenFiles : 99999,
backlogSize : 512,
backlogSize : 3000,
};

@@ -23,30 +22,30 @@

var keepAliveRe = /Connection: keep-alive/i;
net.createServer(opt, function(conn) {
var buf = '';
conn.on('data', function(data) {
buf += data;
});
net.createServer(opt, onconnect).listen(process.argv[3] || 8080);
conn.on('end', function(data) {
buf += data;
function onconnect(conn) {
var str = 'Hello World ' + conn.fd;
var keepalive = keepAliveRe.test(buf);
str = odata;
var header = 'HTTP/1.1 200 OK\r\n';
conn.on('data', ondata);
conn.on('end', onend);
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
}
conn.write(str);
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
str = odata;
var header = 'HTTP/1.1 200 OK\r\n';
} else {
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
conn.end(str);
}
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
buf = '';
});
this.write(str);
}).listen(process.argv[4] || 8080);
} else {
str = header + 'Content-Length: ' + (str.length) + '\r\n\r\n' + str;
this.end(str);
}
}
function onend() {
}

@@ -6,5 +6,4 @@ var net = require('thread.js').net;

rtransportNum : process.argv[2],
wtransportNum : process.argv[3],
sysOpenFiles : 99999,
backlogSize : 512,
backlogSize : 3000,
};

@@ -22,35 +21,34 @@

var keepAliveRe = /Connection: keep-alive/i;
net.createServer(opt, function(conn) {
var buf = '';
conn.on('data', function(data) {
buf += data;
});
net.createServer(opt, onconnect).listen(process.argv[3] || 8080);
conn.on('end', function(data) {
buf += data;
function onconnect(conn) {
var str = 'Hello World ' + conn.fd;
var keepalive = keepAliveRe.test(buf);
var header = 'HTTP/1.1 200 OK\r\n';
conn.on('data', ondata);
conn.on('end', onend);
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
}
conn.write(dv);
function ondata(data) {
var str = '';
var keepalive = keepAliveRe.test(data);
var header = 'HTTP/1.1 200 OK\r\n';
} else {
if (keepalive === true) {
header += 'Connection: keep-alive\r\n';
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
this.write(dv);
conn.end(dv);
}
} else {
buf = '';
});
str = header + 'Content-Length: ' + (odataBody.byteLength) + '\r\n\r\n';
var dv = prependBuffer(str, AB, headerPreserveSize, -1);
}).listen(process.argv[4] || 8080);
this.end(dv);
}
}
function onend() {
}

@@ -57,0 +55,0 @@ function prependBuffer(str, ab, headerPreserveSize, litterEndian) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc