-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
33 lines (29 loc) · 840 Bytes
/
client.js
File metadata and controls
33 lines (29 loc) · 840 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
const { createQuicSocket } = require('net')
// this one exists in nodejs 15.0.0 compiled with --experimental-quic
console.log(createQuicSocket);
// perf
let msg = 0;
setInterval(() => {
console.log("Total messages per second: " + msg);
msg = 0;
}, 1000);
for (let i = 0; i < 40; i++) {
createQuicSocket().connect({
address: 'localhost',
port: 5678,
alpn: 'echo',
}).then((s) => {
s.on('sessionError', () => {
console.log("session error client");
});
s.on('secure', (host) => {
s.openStream().then((s) => {
s.write("hello biatch: " + i);
s.on('data', (chunk) => {
msg++;
s.write(chunk);
});
});
})
});
}