Created
May 3, 2017 15:56
-
-
Save adulau/ee4c22f478c318a0569a9526f3a50458 to your computer and use it in GitHub Desktop.
zmq-feed
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
# | |
# Sample script to connect to CIRCL datafeeds | |
# Requirements: | |
# - Recent version of ZMQ (and the associated Python library) | |
# - Access to the feed (you need to provide a static IP address to | |
# [email protected]) | |
# | |
import sys | |
import zmq | |
port = "5556" | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
socket.connect ("tcp://crf.circl.lu:%s" % port) | |
topicfilter = "102" | |
socket.setsockopt(zmq.SUBSCRIBE, topicfilter) | |
while True: | |
message = socket.recv() | |
try: | |
topic, paste, messagedata = message.split() | |
except ValueError: | |
print "Empty paste :" + message | |
continue | |
print paste, messagedata |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment