#!/usr/bin/python
############
# UDP_Server.py 
# This program listens for
# UDP connections from UDP_Client.py
############ 

# First import socket and set up variables
import socket

My_Host = "127.0.0.1"
My_Port = 5555

# Create the socket instance
My_Socket = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )

# Bind the socket to host and port
My_Socket.bind( ( My_Host, My_Port ) )

# While loop that listens for connections and prints information

while 1:
   
   Received_Packet, address = My_Socket.recvfrom( 1024 )
   print "Packet received:"
   print "From host:", address[ 0 ]
   print "Host port:", address[ 1 ]
   print "Containing:"
   print "\n" + Received_Packet
   # Send data back to client	
   print "\ndata to client...",
   My_Socket.sendto( Received_Packet, address )
   print "Packet sent\n"



