How to Solve NameError: name 'SOCK_DGRAM' is not defined -- socket

Solution: Import the 'SOCK_DGRAM' module

To Solve the error, add the following line to the top of your code.

from socket import SOCK_DGRAM

 

For more information:
Python socket SOCK_DGRAM