Skip to content

Instantly share code, notes, and snippets.

@adulau
Created May 3, 2017 15:56
Show Gist options
  • Save adulau/ee4c22f478c318a0569a9526f3a50458 to your computer and use it in GitHub Desktop.
Save adulau/ee4c22f478c318a0569a9526f3a50458 to your computer and use it in GitHub Desktop.
zmq-feed
#
# 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