forked from zeromq/chumak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pair_server.erl
26 lines (23 loc) · 882 Bytes
/
pair_server.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at http://mozilla.org/MPL/2.0/.
-module(pair_server).
-export([main/0]).
main() ->
application:start(chumak),
{ok, Socket} = chumak:socket(pair),
case chumak:bind(Socket, tcp, "localhost", 5555) of
{ok, _BindPid} ->
io:format("Binding OK with Pid: ~p\n", [Socket]);
{error, Reason} ->
io:format("Connection Failed for this reason: ~p\n", [Reason]);
X ->
io:format("Unhandled reply for bind ~p \n", [X])
end,
loop(Socket).
loop(Socket) ->
ok = chumak:send_multipart(Socket, [<<"Hey Jude">>]),
io:format("Sent\n"),
{ok, Data2} = chumak:recv_multipart(Socket),
io:format("Received ~p\n", [Data2]),
loop(Socket).