Skip to content

Instantly share code, notes, and snippets.

@sandeep048
Created January 9, 2016 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandeep048/9d107eda7d213ce1c3dd to your computer and use it in GitHub Desktop.
Save sandeep048/9d107eda7d213ce1c3dd to your computer and use it in GitHub Desktop.
# 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