Skip to content

Instantly share code, notes, and snippets.

@hintjens
hintjens / listener.c
Created December 8, 2012 11:28
How to broadcast a file to a distributed network
#include <zre.h>
int main (int argc, char *argv [])
{
zre_interface_t *interface = zre_interface_new ();
while (true) {
zmsg_t *incoming = zre_interface_recv (interface);
if (!incoming)
break;
zmsg_dump (incoming);
@hintjens
hintjens / gist:4053950
Created November 11, 2012 06:32
inetd test
#include "czmq.h"
void
s_log (FILE *output, const char *format, ...)
{
time_t curtime = time (NULL);
struct tm *loctime = localtime (&curtime);
char formatted [20];
strftime (formatted, 20, "%y-%m-%d %H:%M:%S ", loctime);
fprintf (output, "%s", formatted);
#include <assert.h>
#include <inttypes.h>
#include "zmq.h"
int main (void)
{
void *context = zmq_init (1);
void *socket = zmq_socket (context, ZMQ_SUB);
uint64_t one = 1;
@hintjens
hintjens / gist:1030232
Created June 16, 2011 20:46
Patch to log major events to syslog
From 606fb49dca15fcc44f9018f30415c13abaa2251f Mon Sep 17 00:00:00 2001
From: Pieter Hintjens <[email protected]>
Date: Thu, 17 Feb 2011 16:23:01 +0100
Subject: [PATCH 149/149] Added syslog reporting of some major events in 0MQ
- log method in object base class sends formatted report to sys://log.
- xrep warns when it cannot route a message due to an unknown envelope identity
- session warns when it disconnects a peer due to duplicate identity
Signed-off-by: Pieter Hintjens <[email protected]>
@hintjens
hintjens / base2
Created May 3, 2011 14:54
Diffs from 1.3d0 to 1.3d1
Index: asl/asl_client_session.gsl
===================================================================
--- asl/asl_client_session.gsl (revision 12077)
+++ asl/asl_client_session.gsl (revision 12145)
@@ -609,7 +609,7 @@
<private name = "header">
static int
- s_wait_for_methods ($\(selftype) *self, int timeout, Bool blocking, Bool on_content);
+ s_wait_for_methods ($\(selftype) *self, int timeout, Bool blocking, Bool want_content);
@hintjens
hintjens / .gitignore
Created April 28, 2011 08:44
Code for issue 191
*.o
core
pub
sub
pub2
sub2
@hintjens
hintjens / issue188
Created March 31, 2011 07:37
pubsub.c
//
// Test multipart pub-sub
// Causes assertion failure in fw.cpp:62
//
#include "zmq.h"
#include <pthread.h>
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
@hintjens
hintjens / bb2wd.pl
Created March 29, 2011 19:47
pygmentize bb to wikidot
#! /usr/bin/perl
#
# Converts a pygment bb output file to Wikidot markup
# Used to create syntax-colored listings without HTML
#
$/ = undef;
$_ = <>;
# [/i][/color] often comes at start of next line for some reason
s/\n\[\/i\]/\[\/i\]\n/mg;
@hintjens
hintjens / zeromq.spec
Created March 21, 2011 20:05
Fixed for 2.1.3 release
Name: zeromq
Version: @PACKAGE_VERSION@
Release: 1%{?dist}
Summary: The ZeroMQ messaging library
Group: Applications/Internet
License: LGPLv3+
URL: http://www.zeromq.org/
Source: http://www.zeromq.org/local--files/area:download/%{name}-%{version}.tar.gz
Prefix: %{_prefix}
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
@hintjens
hintjens / client.c
Created March 18, 2011 11:53
Client reports when it gets a confused message
//
// Clone client model 1
//
#include "zhelpers.h"
int main (void)
{
s_catch_signals ();
while (!s_interrupted) {
// Prepare our context and socket