UDP (User Datagram Protocol) is a connectionless transport layer protocol that sends data without establishing a connection, making it fast but unreliable.
Elaboration:
- No handshake mechanism, unlike TCP, so data may be lost.
- Used in applications where speed is more critical than reliability (e.g., live streaming, VoIP, gaming).
- Works on port 53 (DNS), port 67/68 (DHCP), port 161 (SNMP), etc.
Example:
Online multiplayer games like PUBG or Fortnite use UDP for real-time data transmission.
Code Example: (Simple UDP Server)
pythonCopyEditimport socket
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server.bind(("0.0.0.0", 12345))
data, addr = server.recvfrom(1024)
print(f"Received {data} from {addr}")
Leave a Reply