Net

Understand the workings of the net module in Node.js.

TCP

One of the most common transport layer protocols is TCPTransmission Control Protocol. It provides a reliable way of sending packets in an ordered and error-checked stream. TCP is connection-oriented, which means that a connection must be established between the client and the server before data can be sent. We will not delve into the details of how that works, as that is beyond the scope here. Still, it is important to know how it works, as it will help us understand the difference between TCP and UDP.

net

The net module provides an asynchronous network API for creating stream-based TCP or IPCInter-Process Communication servers. Let’s see how we can make a simple TCP server. Run the code below.

Get hands-on with 1200+ tech skills courses.