Last active
April 6, 2016 18:37
-
-
Save abhigenie92/9e9d09715c7fd7668e0a0e5445bf046f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet.protocol import DatagramProtocol | |
from twisted.internet import reactor | |
class EchoClientDatagramProtocol(DatagramProtocol): | |
def startProtocol(self): | |
self.transport.connect('127.0.0.1', 8000) | |
self.sendDatagram() | |
def sendDatagram(self): | |
self.transport.write('hello') | |
def datagramReceived(self, datagram, host): | |
print 'Datagram received: ', repr(datagram) | |
self.sendDatagram() | |
def main(): | |
protocol = EchoClientDatagramProtocol() | |
t = reactor.listenUDP(0, protocol) | |
reactor.run() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment