How to : UDP server with NodeJs

Khalil SAIDI
Quick Code
Published in
6 min readJan 15, 2022

--

In this tutorial you’ll learn how to set up and code a UDP server with NodeJs with simple words and step by step from scratch !

After following this tutorial, you’ll understand how it works and be able to code a UDP server, UDP client and exchange data between them using NodeJs !

(The example are based on Windows, but it will be the same thing for Linux..)

Photo by Markus Spiske on Unsplash

What is UDP ?

UDP stands for User Datagram Protocol is one of the TCP/IP internet protocols.

Using UDP you can exchange data (called a datagram) with a server.

What you have to remember is :

  • UDP is a connectionless communication protocol (no need of “handshake” with the server to set up the communication, no need to set up end-to-end communication …)
  • Unreliable(the sender doesn't know if the message was received by the receiver, no retransmission,...)
  • Messages not ordered : the messages received by the receiver are not necessarily received in the same order when messages were sent (so you need to manage messages order)
  • ….

But it makes UDP Lightweight and simple to set up !

--

--