udt4twisted / examples / newserver.py

import sys

from udt4twisted import udtepollreactor

from twisted.python import log
from twisted.internet import reactor, defer
from twisted.internet.protocol import DatagramProtocol, Protocol, Factory
from twisted.python import log
from udt4twisted import udt

class Echo(Protocol):
    def connectionMade(self):
        print "CONN MADE!"
        self.transport.write("An apple a day keeps the doctor away\r\n")

    def dataReceived(self, data):
        log.msg("received {0} from {1}".format(data, self.transport.getPeer()))
        print "?", self.transport.write(data)

    def connectionLost(self, reason):
        print "CONN LOST!"

class EchoFactory(Factory):
    def buildProtocol(self, addr):
        return Echo()

class Tester(object):
    port = None
    def listen_to_udt_port(self, res):
        self.echo = EchoFactory()
        self.port = reactor.tlistenUDT(5000, self.echo)
        print self.port

    def print_hello(self, res):
        print "Hello!"
        return "hello"

    def bye(self):
        print self.port
        print "Bye!"

d = defer.Deferred()
test = Tester()


reactor.callLater(0.3, d.callback, 1)
reactor.callLater(100, test.bye)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.