-
-
Save PirosB3/7180622 to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
#include "zmq.h" | |
int main() { | |
void *context = zmq_ctx_new(); | |
void *in_sock = zmq_socket(context, ZMQ_SUB); | |
zmq_connect(in_sock, "tcp://127.0.0.1:8081"); | |
zmq_setsockopt(in_sock, ZMQ_SUBSCRIBE, "[TICKER]", 8 * sizeof(char)); | |
printf("Entering loop mode..\n"); | |
printf("Listening for [CHATTR] on tcp://127.0.0.1/8081\n"); | |
while(1) { | |
zmq_msg_t msg; | |
zmq_msg_init(&msg); | |
zmq_recvmsg(in_sock, &msg, 0); | |
printf("OKAY\n"); | |
} | |
} |
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
import time | |
import zmq | |
def main(): | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
socket.connect('tcp://127.0.0.1:8081') | |
socket.setsockopt(zmq.SUBSCRIBE, "[TICKER]") | |
print "Listening for [TICKER] on tcp://127.0.0.1:8081" | |
while True: | |
msg = socket.recv() | |
print msg | |
if __name__ == '__main__': | |
main() |
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
import time | |
import zmq | |
def main(): | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.bind('tcp://*:8081') | |
while True: | |
socket.send("[TICKER] tick") | |
print "ticked.." | |
time.sleep(1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment