-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #854 from shishirpy/master
Erlang "hw*" example to chumak
- Loading branch information
Showing
4 changed files
with
41 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file was deleted.
Oops, something went wrong.