Project-Dgram is a simple and educational Node.js project that demonstrates how to work with the User Datagram Protocol (UDP).
UDP divides data into small packets called datagrams and sends them directly to the destination — without establishing a connection — making it fast, lightweight, and perfect for real-time communication.
- Send and receive UDP datagrams using Node.js
- Understand connectionless communication
- Lightweight and easy to modify for experiments
- Great for learning or network debugging
UDP (User Datagram Protocol) is one of the main transport-layer protocols in the Internet Protocol (IP) suite.
It sends independent packets of data called datagrams with minimal overhead.
Unlike TCP:
- It does not guarantee delivery
- It does not check for errors
- It does not ensure order
This makes it faster and more efficient for time-critical data transmission.
| Advantage | Description |
|---|---|
| ⚡ Speed | No connection setup — faster data delivery |
| 🧠 Low Overhead | Smaller headers and less processing per packet |
| 📡 Broadcast & Multicast Support | Ideal for one-to-many communication |
| 🔗 Connectionless | No handshaking, lower latency |
| 💬 Perfect for Real-Time Apps | Used in games, VoIP, live streaming, and IoT |
| 🔁 Small Data Transfers | Efficient for short or repetitive messages |
const dgram = require('dgram');
const server = dgram.createSocket('udp4');
server.on('message', (msg, rinfo) => {
console.log(`Received: ${msg} from ${rinfo.address}:${rinfo.port}`);
});
server.bind(41234, () => {
console.log('UDP Server is listening on port 41234');
});