Open drozzy opened 7 years ago
Looking for contributors.
if you could get me an example of actually using chumak in a gen_server, I'd happily help sort ouf the rest of the docs. The examples/ aren't idiomatic for some people, even those experienced in Erlang, to get as far as hello world.
I haven’t looked into this in a while, so I’m afraid I can’t help. Hopefully someone can figure out how to make it idiomatic. Feel free to hack the core code. My intent was to just provide a starting point.
I would like to help with this, @mk270 could you tell you mean by idiomatic examples, I have tried the following code example and it is working:
The server module is:
-module(hwserver).
-export([main/0]).
main() ->
application:start(chumak),
{ok, Socket} = chumak:socket(rep, "my-rep"),
io:format("~p", [Socket]),
{ok, Pid} = chumak:bind(Socket, tcp, "localhost", 5555),
loop(Socket).
loop(Socket) ->
{ok, RecvMessage} = chumak:recv(Socket),
io:format("Received request : ~p\n", [RecvMessage]),
timer:sleep(1000),
chumak:send(Socket, "World"),
loop(Socket).
and the client module is:
-module(hwclient).
-export([main/0]).
main() ->
application:start(chumak),
{ok, Socket} = chumak:socket(req, "my-req"),
{ok, Pid} = chumak:connect(Socket, tcp, "localhost", 5555),
loop(Socket).
loop(Socket) ->
chumak:send(Socket, "Hello"),
{ok, RecvMessage} = chumak:recv(Socket),
io:format("Recv Reply: ~p\n", [RecvMessage]),
loop(Socket).
@drozzy what is the equivalent of socket.close()
in chumak
? I am trying to implement the lazy pirate
pattern, where one has to close the socket and restart a new one in no response arrives in fixed timeout.
As I remember there was some discussion similar to this before, but I don't think anything was actually decided: https://github.com/zeromq/chumak/pull/19 https://github.com/zeromq/chumak/issues/18
@drozzy any idea how to have an unblocking
receive command? Trying to implement msreader
https://github.com/booksbyus/zguide/blob/master/examples/Erlang/msreader.es
@shishirpy you may have more luck on Erlang discussion forums: https://www.erlang.org/community I'm not actively maintaining this - I only try to keep up with MRs.
Re-implement all the zguide Erlang examples in Chumak: https://github.com/booksbyus/zguide/tree/master/examples
This will serve to document the library and iron out any quirks in the library.