Commit c133fa9
committed
Add -sNODERAWSOCKETS backend for real TCP & UDP on Node.js
This adds a new `-sNODERAWSOCKETS` setting that for supporting direct full sockets on Node.js via the `node:net` for TCP and `node:dgram` for UDP modules, without needing `ws`, an external proxy process, or pthreads.
* Full support for both outgoing and incoming TCP, using the `node:net` APIs.
* Full support for UDP using the `node:dgram` APIs
* Support for threading, with tests
* Support for IPV6
To support these embeddings without JSPI being mandatory requires using `process.binding('tcp_wrap')` and `process.binding('udp_wrap')` in Node.js, which are used here to support older versions of Node.js.
Further, to avoid having to rely on private APIs in modern Node.js I actually implemented upstream Node.js PRs to make public API surface area available for the full embedding in the following:
* nodejs/node#63838
* nodejs/node#63932
* nodejs/node#63951
* nodejs/node#63825
Then this PR conditionally checks these features and uses the public APIs as defined by them when it is able to, falling back to `tcp_wrap` and `udp_wrap` only when not supported. While Node.js with these features has not yet been released, as soon as all three have landed, we can rely on this surface area for modern 26+ versions of Node.js compat.1 parent 4177187 commit c133fa9
29 files changed
Lines changed: 2399 additions & 45 deletions
File tree
- site/source/docs/tools_reference
- src
- lib
- system/lib
- libc
- wasmfs
- test
- codesize
- sockets
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
591 | 620 | | |
592 | 621 | | |
593 | 622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | | - | |
48 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
| |||
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| 80 | + | |
| 81 | + | |
72 | 82 | | |
73 | 83 | | |
74 | 84 | | |
| |||
726 | 736 | | |
727 | 737 | | |
728 | 738 | | |
729 | | - | |
| 739 | + | |
730 | 740 | | |
731 | 741 | | |
732 | 742 | | |
| |||
0 commit comments