Skip to content

Instantly share code, notes, and snippets.

@christian-marie
Created December 20, 2013 04:11
Show Gist options
  • Save christian-marie/8050320 to your computer and use it in GitHub Desktop.
Save christian-marie/8050320 to your computer and use it in GitHub Desktop.
#include <zmq.h>
#include <stdlib.h>
#include "assert.h"
int main() {
void *c = zmq_ctx_new();
assert(c);
void *s = zmq_socket(c, ZMQ_PUSH);
assert(s);
int ret = zmq_connect( s, "tcp://localhost:1234" );
assert( ret != -1 );
int hwm = 100;
zmq_setsockopt( c, ZMQ_SNDHWM, &hwm, sizeof( hwm ) );
#define SIZE 2097152
char* buf = malloc(SIZE);
int i;
for(i=0; i<SIZE; i++)
buf[i] = 'A';
ret = zmq_send(s, buf, SIZE, ZMQ_DONTWAIT);
assert( ret != -1 );
zmq_close(s);
zmq_ctx_destroy(c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment