Created
August 10, 2010 16:43
-
-
Save minrk/517566 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
# Quick python script to send a single message to the PAIR socket | |
# this will crash the device | |
import zmq | |
ctx = zmq.Context() | |
s = ctx.socket(zmq.PAIR) | |
s.connect('tcp://127.0.0.1:5555') | |
s.send('invalid') |
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
/* | |
This starts a simple Queue device, with XREP on one side, and PAIR on the other | |
A length 1 message to the PAIR socket will bring down the device. | |
This is true for any socket in place of the PAIR that doesn't prepend an IDENTITTY to | |
incoming messages. | |
It is also true for any device type. | |
*/ | |
#include <assert.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <zmq.h> | |
int main () | |
{ | |
int rc; | |
void *ctx, *s, *xrep; | |
/* Initialise 0MQ context, requesting a single I/O thread */ | |
ctx = zmq_init (1); | |
assert (ctx); | |
// start sockets | |
s = zmq_socket (ctx, ZMQ_PAIR); | |
assert (s); | |
xrep = zmq_socket (ctx, ZMQ_XREP); | |
assert(xrep); | |
rc = zmq_bind (s, "tcp://127.0.0.1:5555"); | |
assert (rc == 0); | |
rc = zmq_bind (xrep, "tcp://127.0.0.1:5556"); | |
assert (rc == 0); | |
// create the device | |
zmq_device(ZMQ_QUEUE, s, xrep); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment