Skip to content

Commit

Permalink
Merge pull request #854 from shishirpy/master
Browse files Browse the repository at this point in the history
Erlang "hw*" example to chumak
  • Loading branch information
sappo authored Jul 24, 2021
2 parents 19575df + 4f878c6 commit 768aecc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 58 deletions.
21 changes: 21 additions & 0 deletions examples/Erlang/hwclient.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-module(hwclient).
-export([main/0]).

%%
%% "Hello world" client example.
%% Connects to tcp://localhost:5555
%% Sends <<"Hello">> to server and prints the response
%%

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).
27 changes: 0 additions & 27 deletions examples/Erlang/hwclient.es

This file was deleted.

20 changes: 20 additions & 0 deletions examples/Erlang/hwserver.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-module(hwserver).
-export([main/0]).

%% Starts a local hello server.
%% Binds to tcp://localhost:5555

main() ->
application:start(chumak),
{ok, Socket} = chumak:socket(rep, "my-rep"),
{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).
31 changes: 0 additions & 31 deletions examples/Erlang/hwserver.es

This file was deleted.

0 comments on commit 768aecc

Please sign in to comment.