Introduction to the UDP protocol

UDP is a protocol that is on the same level as TCP, that is, above the IP layer. It offers a service in disconnected mode to the applications that use it. This protocol is suitable for applications that require efficient communication that doesn't have to worry about packet loss. The typical applications of UDP are internet telephony and video-streaming. The header of a UDP frame is composed of four fields:

  • The UDP port of origin
  • The UDP destination port
  • The length of the UDP message
  • The chekSum as the error-control field

The only difference regarding working with TCP in Python is that when creating the socket, you have to use SOCK_DGRAM instead of SOCK_STREAM.

The main difference between TCP and UDP is ...

Get Mastering Python for Networking and Security now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.