aboutsummaryrefslogtreecommitdiff
path: root/inputs/UDPInput.py
blob: e95bd330c8ba96c6c63ad7ee74f1b0fb22fc120a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
from operationscore.Input import *
import socket
class UDPInput(Input):
    def inputInit(self):
        HOST = ''                 # Symbolic name meaning all available interfaces
        PORT = self.argDict['Port']              # Arbitrary non-privileged port
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.bind((HOST, PORT))
    def sensingLoop(self):
        (data,address) = self.sock.recvfrom(1024)
        dataDict = {'data':data, 'address':address}
        self.respond(dataDict)