Assignment 6
Assignment 6
THEORY:
1. Introduction to UDP
UDP (User Datagram Protocol) is a connectionless, lightweight transport layer protocol in the
TCP/IP suite. Unlike TCP, UDP does not establish a connection before data transmission and
does not provide error correction or retransmission. It is widely used for real-time
applications such as video streaming, VoIP, and online gaming.
2. Features of UDP
Low Overhead: Faster than TCP since it lacks handshaking and error control.
Bind the socket to an IP address and port using the bind() function.
CODE:
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
try {
while (true) {
serverSocket.receive(receivePacket);
serverSocket.send(sendPacket);
} catch (Exception e) {
e.printStackTrace();
} finally {
serverSocket.close();
OUTPUT:
THEORY:
1. Introduction to UDP
UDP (User Datagram Protocol) is a lightweight, connectionless transport layer protocol used
for fast and efficient data transfer. Unlike TCP, UDP does not establish a connection before
data transmission, making it ideal for real-time applications like video streaming, VoIP, and
online gaming.
2. Features of UDP
Fast and Efficient: Minimal overhead, making it suitable for real-time applications.
A UDP client sends messages (datagrams) to a server without establishing a connection. The
client does not wait for acknowledgment and does not retry if data is lost.
CODE:
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
try {
clientSocket.send(sendPacket);
clientSocket.receive(receivePacket);
} catch (Exception e) {
e.printStackTrace();
} finally {
OUTPUT:
CONCLUSION:
UDP (User Datagram Protocol) is a connectionless, fast, and lightweight transport layer
protocol used in socket programming for real-time and high-speed applications. Unlike TCP,
UDP does not guarantee reliability, sequencing, or error correction, making it suitable for
scenarios where speed is prioritized over accuracy.
LO MAPPING:
LO 4 ACHIEVED.