Created
July 21, 2016 16:32
-
-
Save Su-Shee/892200cbb50cae5e9262e4e1fe5def21 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
use ZMQ::LibZMQ4; | |
use ZMQ::Constants qw/:all/; | |
my $ctxt = zmq_init; | |
my $socket = zmq_socket( $ctxt, ZMQ_PUB); | |
zmq_bind( $socket, "tcp://127.0.0.1:9999" ); | |
while (1) { | |
say "sending..."; | |
my $howmuch = zmq_msg_send( "HELLO HELLO HELLO", $socket ); | |
say "sent: $howmuch"; | |
sleep(5); | |
} | |
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
use ZMQ::LibZMQ4; | |
use ZMQ::Constants qw/:all/; | |
my $ctxt = zmq_init; | |
my $socket = zmq_socket( $ctxt, ZMQ_SUB); | |
zmq_connect( $socket, "tcp://127.0.0.1:9999" ); | |
zmq_setsockopt( $socket, ZMQ_SUBSCRIBE, '' ); | |
my $msg = zmq_msg_init(); | |
say "receiving..."; | |
say zmq_msg_recv( $msg, $socket ); | |
say zmq_msg_data( $msg ); | |
say "got it!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment