Implementing a simple UDP client and UDP server
In this section, we will review how you can set up your own UDP client-server application with Python’s socket module. The application will be a server that listens for all connections and messages over a specific port and prints out any messages to the console that have been exchanged between the client and server.
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 and don’t have to worry about packet loss. Typical applications of UDP are internet telephony and video streaming.
The only difference between working with TCP and UDP in Python is that when creating the socket in UDP, you need to use SOCK_DGRAM
instead of SOCK_STREAM
. The main difference between TCP and UDP is that UDP is not connection-oriented, and this means that there...