December 2018
Intermediate to advanced
642 pages
15h 5m
English
Using .fork() implies that the child process is a Node process, so instead of expressly mentioning it, as we did in the previous section, we just have to pass the name of the JS file to be executed.
The second difference, as we mentioned, is that instead of using stdin and stdout for communication, we can .send() a message (in any direction, from parent to child or vice versa) and we listen to the "message" event instead of the "data" one.
If you analyze the highlighted differences in code, you'll realize that the differences are really minor, and for the special (but not uncommon) case of needing to run a separate Node process, .fork() is more appropriate, and possibly a tad simpler to use.
Read now
Unlock full access