Package SmootLight :: Package inputs :: Module UDPInput
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.inputs.UDPInput

 1  from operationscore.Input import * 
 2  import socket 
3 -class UDPInput(Input):
4 """UDPInput is a barebones UDP Input class. It takes any data it receives and adds it to the 5 'data' element of the response dict. It also notes the 'address'. Specify: 6 <Port> -- the Port to listen on.""" 7
8 - def inputInit(self):
9 HOST = '' # Symbolic name meaning all available interfaces 10 PORT = self.argDict['Port'] # Arbitrary non-privileged port 11 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 12 self.sock.bind((HOST, PORT))
13 - def sensingLoop(self):
14 (data,address) = self.sock.recvfrom(1024) 15 dataDict = {'data':data, 'address':address} 16 self.respond(dataDict)
17