0% found this document useful (0 votes)
10 views2 pages

UDP Theory

UDP (User Datagram Protocol) is a connectionless transport protocol that allows applications to send data quickly without the overhead of establishing a connection, making it faster but less reliable than TCP. The document outlines basic steps for client-server communication using UDP, detailing the processes for both server and client sides. Key characteristics of UDP include no connection establishment, faster transmission, unreliability in data delivery, and support for broadcasting/multicasting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

UDP Theory

UDP (User Datagram Protocol) is a connectionless transport protocol that allows applications to send data quickly without the overhead of establishing a connection, making it faster but less reliable than TCP. The document outlines basic steps for client-server communication using UDP, detailing the processes for both server and client sides. Key characteristics of UDP include no connection establishment, faster transmission, unreliability in data delivery, and support for broadcasting/multicasting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Definition of UDP

UDP (User Datagram Protocol) is a connectionless, lightweight transport protocol used in the
Internet Protocol (IP) suite. It provides a way for applications to send data, called datagrams, without
the overhead of establishing and maintaining a connection. UDP is faster but less reliable compared
to TCP, as it does not guarantee delivery, order, or error checking of the data.

Basic Steps for Client-Server Communication using UDP

Here is a simplified outline of how UDP communication works between a client and server:

Server Side:

1. Create a UDP Socket


Use the socket library to create a socket configured for UDP communication.

server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

2. Bind to an Address and Port


Associate the socket with a specific address and port to listen for incoming messages.

server_socket.bind(('server_address', port))

3. Receive Data
Wait for data from clients. The recvfrom() method retrieves the message and the client's
address.

data, client_address = server_socket.recvfrom(buffer_size)

4. Process and Respond


Process the received data and optionally send a response to the client.

server_socket.sendto(response_data, client_address)

Client Side:

1. Create a UDP Socket


Create a socket for UDP communication.

client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

2. Send Data
Send data to the server using the sendto() method.

client_socket.sendto(data, ('server_address', port))

3. Receive Response (Optional)


If the server sends a response, use recvfrom() to receive it.

response, server_address = client_socket.recvfrom(buffer_size)

4. Close the Socket


Close the socket once communication is complete.

client_socket.close()
Key Characteristics of UDP:

• No Connection: No connection is established before sending data.

• Faster Transmission: Lower latency compared to TCP.

• Unreliable: No guarantee of data delivery, order, or error checking.

• Broadcasting/Multicasting: Supports sending messages to multiple devices.

You might also like