Permalink
Browse files

Adding C distro

  • Loading branch information...
1 parent 54f49e9 commit 0f1104587a7e2ad59cb45503f0e2c7cdc208ab94 @ianbarber committed Jun 10, 2011
Showing with 26 additions and 15 deletions.
  1. +1 −1 log/logserv.erl
  2. +8 −12 queue/queue.erl
  3. +1 −1 reqrep/erlrep.erl
  4. +15 −0 statusupdate/distro.c
  5. +1 −1 statusupdate/eventhub.erl
View
@@ -9,7 +9,7 @@ run() ->
loop(In) ->
receive
- {zmq, In, Msg} ->
+ {zmq, In, Msg, _Flags} ->
{ok,{obj, [{_, Time}, {_, Log}] }, [] } = rfc4627:decode(Msg),
io:format("~B ~s~n", [Time, Log]),
loop(In)
View
@@ -14,23 +14,19 @@ run() ->
ok = erlzmq:close(Back),
ok = erlzmq:term(Ctx).
-% using my fork of the bindings here, as multipart support in
-% erlzmq2 works slightly differently in master
loop(Front, Back) ->
receive
- {zmq, Front, Msg} ->
+ {zmq, Front, Msg, Flags} ->
io:format("Sending Back: ~p~n",[Msg]),
- sendall(Back, Msg),
+ sendall(Back, Msg, Flags),
loop(Front, Back);
- {zmq, Back, Msg} ->
+ {zmq, Back, Msg, Flags} ->
io:format("Sending Front: ~p~n",[Msg]),
- sendall(Front, Msg),
+ sendall(Front, Msg, Flags),
loop(Front, Back)
end.
-sendall(To, [Part|[]]) ->
- erlzmq:send(To, Part);
-
-sendall(To, [Part|Msg]) ->
- erlzmq:send(To, Part, [sndmore]),
- sendall(To, Msg).
+sendall(To, Part, [rcvmore|_Flags]) ->
+ erlzmq:send(To, Part, [sndmore]);
+sendall(To, Part, _Flags) ->
+ erlzmq:send(To, Part).
View
@@ -8,7 +8,7 @@ run() ->
loop(Socket).
loop(Socket) ->
- {ok, Msg} = erlzmq:recv(Socket),
+ {ok, Msg, _F} = erlzmq:recv(Socket),
Reply = binary_to_list(Msg) ++ " World",
io:format("Sending ~s~n", [Reply]),
ok = erlzmq:send(Socket, list_to_binary(Reply)),
View
@@ -0,0 +1,15 @@
+#include <zmq.h>
+
+int main(void) {
+ void *ctx = zmq_init(1);
+ void *in = zmq_socket(ctx, ZMQ_SUB);
+ void *out = zmq_socket(ctx, ZMQ_PUB);
+ zmq_setsockopt(in, ZMQ_SUBSCRIBE, "", 0);
+ int rcin = zmq_connect(in, "epgm://;239.192.0.1:7601");
+ int rcout = zmq_bind(out, "ipc:///tmp/events");
+
+ int rcd = zmq_device(ZMQ_FORWARDER, in, out);
+
+ zmq_close(in); zmq_close(out); zmq_term(ctx);
+ return 0;
+}
@@ -11,6 +11,6 @@ run() ->
loop(In, Out).
loop(In, Out) ->
- {ok, Msg} = erlzmq:recv(In),
+ {ok, Msg, _F} = erlzmq:recv(In),
ok = erlzmq:send(Out, Msg),
loop(In, Out).

0 comments on commit 0f11045

Please sign in to comment.