Created
August 25, 2016 19:32
-
-
Save stisa/e98712bccd04b8a1c83863ec6b9f993b 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
import zmq | |
# Example in cpp: | |
# http://zguide.zeromq.org/cpp:mspoller | |
var spm2 = zmq.connect("tcp://localhost:5556", zmq.Dealer) | |
var conn2 = zmq.listen("tcp://*:5556", zmq.ROUTER) | |
var spm = zmq.connect("tcp://localhost:5555",zmq.Dealer) | |
var conn = zmq.listen("tcp://*:5555", zmq.ROUTER) | |
var pollitem : TPollItem | |
var pollitem2 : TPollItem | |
var pollarr : array[2,TPollItem] | |
pollitem.socket = conn.s | |
pollitem.events = ZMQ_POLLIN | |
pollitem2.socket = conn2.s | |
pollitem2.events = ZMQ_POLLIN | |
pollarr[0] = pollitem | |
pollarr[1] = pollitem2 | |
# This is zmq.poll: | |
# proc poll*(items: ptr TPollItem, nitems: cint, timeout: int): cint{. | |
# cdecl, importc: "zmq_poll", dynlib: zmqdll.} | |
while true: | |
echo poll(addr pollarr[0],2,-1) , " messages waiting" # SIGSEGV, Illegal storage access |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment