blob: 83e2f7797bb621119fcf42096b244d092aa386e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
from operationscore.Input import *
import socket
class UDPInput(Input):
"""UDPInput is a barebones UDP Input class. It takes any data it receives and adds it to the
'data' element of the response dict. It also notes the 'address'. Specify:
<Port> -- the Port to listen on."""
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)
|