Created
January 9, 2016 16:13
-
-
Save sandeep048/9d107eda7d213ce1c3dd to your computer and use it in GitHub Desktop.
This file contains 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
# Copyright (c) Sandeep Pathivada. | |
""" | |
An example unix socket client that recieves heartbeat messages. | |
""" | |
from twisted.internet.protocol import Factory | |
from twisted.protocols.basic import LineReceiver | |
from twisted.internet import reactor, protocol | |
from twisted.internet.task import LoopingCall | |
class HeartBeat(LineReceiver): | |
def connectionMade(self): | |
self.sendLine("Hello From Client") | |
def lineReceived(self, line): | |
print('Received: ' + line) | |
def main(): | |
factory = protocol.ClientFactory() | |
factory.protocol = HeartBeat | |
reactor.connectUNIX('cfri.sock', factory) | |
reactor.run() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment