#!/usr/bin/python from twisted.internet import protocol, reactor from twisted.protocols import basic from twisted.internet.task import LoopingCall class RTPUpdateProtocol(basic.LineReceiver): def __init__(self): self.delimiter = '\n' def ping(self): self.transport.write("PING\n") def connectionMade(self): looper = LoopingCall(self.ping) looper.start(3, True) def lineReceived(self, command): command.strip('\n') print "Got: %s" % command class RTPUpdateFactory(protocol.ServerFactory): protocol = RTPUpdateProtocol reactor.listenTCP(5002, RTPUpdateFactory(), 5, "127.0.0.1") reactor.run()