summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tda.erl17
1 files changed, 9 insertions, 8 deletions
diff --git a/tda.erl b/tda.erl
index bccf84b..49160a7 100644
--- a/tda.erl
+++ b/tda.erl
@@ -13,19 +13,18 @@
associate_request() ->
{ok, UI} = acse:encode('ACSEUserInformationForCSTA', {newDefinition,
#'NewACSEUserInformationForCSTA'{cSTAVersion = [versionFive]}}),
- Pdu = #'AARQ-apdu'{
+ acse:encode('ACSE-apdu', {aarq, #'AARQ-apdu'{
'protocol-version' = [version1],
'application-context-name' = {1, 3, 12, 0, 218},
'user-information' = [#'EXTERNAL'{
'direct-reference' = {1, 3, 12, 0, 285, 200},
- encoding = {'single-ASN1-type', UI}}]},
- acse:encode('ACSE-apdu', {aarq, Pdu}).
+ encoding = {'single-ASN1-type', UI}}]}}).
-start() ->
- register(tda_client, spawn(?MODULE, client, [{dial, ?HOST, ?PORT}])).
+release_request() -> acse:encode('ACSE-apdu', {rlrq, #'RLRQ-apdu'{}}).
-stop() ->
- tda_client ! {logout}.
+start() -> register(tda_client, spawn(?MODULE, client, [{dial, ?HOST, ?PORT}])).
+
+stop() -> tda_client ! {logout}.
client({dial, Host, Port}) ->
io:format("Dial ~p:~p~n", [Host, Port]),
@@ -52,7 +51,9 @@ loop(Sock) ->
loop(Sock);
{logout} ->
io:format("Logout~n", []),
- gen_tcp:close(Sock);
+ {ok, Bye} = release_request(),
+ gen_tcp:send(Sock, Bye),
+ loop(Sock);
{tcp, Sock, Msg} ->
io:format("Reply ~p~n", [Msg]),
case decode(Sock, Msg) of