2010-08-11から1日間の記事一覧

Cでsub

sub.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <zmq.h> #include <assert.h> #define MSG_SIZE 128 int main(int argc, char **argv){ printf("sub start\n"); int rc; void *ctx, *sock; zmq_msg_t msg; assert(ctx = zmq_init(1)); assert(sock = zmq_socket(ctx, ZMQ_SUB)</assert.h></zmq.h></string.h></stdlib.h></stdio.h>…

ZeroMQ C++でsub

http://api.zeromq.org/zmq_cpp.htmlこれを #!/usr/bin/env ruby require 'rubygems' require 'zmq' ctx = ZMQ::Context.new sock= ctx.socket(ZMQ::SUB) sock.connect('tcp://127.0.0.1:5000') sock.setsockopt(ZMQ::SUBSCRIBE, 'count') loop do puts sock…

今度こそZeroMQ C++ bindingからpubする

http://d.hatena.ne.jp/shokai/20100811/1281492751 のC++ binding版 Cの関数のラッパーなので先にCで試してからだったら照らし合わせて(http://api.zeromq.org/zmq_cpp.html)理解が早かった pub.cpp #include <stdio.h> #include <iostream> #include <string> #include <zmq.hpp> #include <boost/format.hpp> usi</boost/format.hpp></zmq.hpp></string></iostream></stdio.h>…

C言語からRubyへ送る

参考:http://www.zeromq.org/docs:cookbook C++ bindingの使い方がいまいちわからなかったのでCのを使っているpub.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <zmq.h> #include <assert.h> int main(int argc, char **argv){ printf("pub start\n"); int rc; void *ctx, *soc</assert.h></zmq.h></string.h></stdlib.h></stdio.h>…