udp_server.py

"""Receive UDP packages.
   by stephan)
"""
from slut import *
from slut.net import UdpServer


class Atlantis(World):
    def onSetup(self):
        self.name = "RJ45 Plugs Are Awesome"
        self.udpserver =  StandardUdpServer(4114)
        #the server can send udp packages too:
        #self.udpserver.write('blah', 'localhost', 4332)

    def onDrawOrtho(self):
        circle(200, 200, 100)


class StandardUdpServer(UdpServer):
    def datagramReceived(self, data, (host, port)):
        print 'from:', host, 'on port:', port
        print 'received:',  data
        #write back to sender, which has to run a udp server:
        #self.write('whatevs!', host, port)


atlantis = Atlantis()
atlantis.run()
Initiated by Stephan Hechenberger
Thanks to CADRE's 103