This sounds like a job for the socket module:
http://docs.python.org/2.7/library/socket.html
You can set up a simple socket like so:
import socket
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print "received message:", data
This example was taken from here: https://wiki.python.org/moin/UdpCommunication