diff options
author | Anders Svensson <[email protected]> | 2013-04-06 16:40:20 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2013-04-11 16:18:57 +0200 |
commit | 3c14f79079d6cb7bc7057c38eab39c0485b4c1c8 (patch) | |
tree | e45b09580d589a06f3880f574a7f284dc31c825f /lib | |
parent | 1b377b3d24596cbfb5b7ce20705dc9fce9aac0b6 (diff) | |
download | otp-3c14f79079d6cb7bc7057c38eab39c0485b4c1c8.tar.gz otp-3c14f79079d6cb7bc7057c38eab39c0485b4c1c8.tar.bz2 otp-3c14f79079d6cb7bc7057c38eab39c0485b4c1c8.zip |
Update example client to allow default local address
Note that the semantics of client:connect/1 have changed slightly: the
second element in an argument 3-tuple is a remote address, the local
address being the transport module's default. Previously it was
interpreted as a common local/remote address.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diameter/examples/code/peer.erl | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/diameter/examples/code/peer.erl b/lib/diameter/examples/code/peer.erl index 8fdeba57bf..b4ee17e4b7 100644 --- a/lib/diameter/examples/code/peer.erl +++ b/lib/diameter/examples/code/peer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2012. All Rights Reserved. +%% Copyright Ericsson AB 2010-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -51,7 +51,6 @@ | {protocol(), ip_address(), non_neg_integer()} | {protocol(), ip_address(), ip_address(), non_neg_integer()}. --define(DEFAULT_ADDR, {127,0,0,1}). -define(DEFAULT_PORT, 3868). %% --------------------------------------------------------------------------- @@ -111,7 +110,7 @@ server({T, Addr, Port}) -> {port, Port}]}]; server(T) -> - server({T, ?DEFAULT_ADDR, ?DEFAULT_PORT}). + server({T, loopback, ?DEFAULT_PORT}). %% client/1 %% @@ -124,21 +123,28 @@ client({all, LA, RA, RP}) -> client({T, LA, RA, RP}) -> [{transport_module, tmod(T)}, - {transport_config, [{ip, addr(LA)}, - {raddr, addr(RA)}, + {transport_config, [{raddr, addr(RA)}, {rport, RP}, - {reuseaddr, true}]}]; + {reuseaddr, true} + | ip(LA)]}]; -client({T, LA, RP}) -> - client({T, LA, LA, RP}); +client({T, RA, RP}) -> + client({T, default, RA, RP}); client(T) -> - client({T, ?DEFAULT_ADDR, ?DEFAULT_ADDR, ?DEFAULT_PORT}). + client({T, loopback, loopback, ?DEFAULT_PORT}). tmod(tcp) -> diameter_tcp; tmod(sctp) -> diameter_sctp. -addr(default) -> - ?DEFAULT_ADDR; +ip(default) -> + []; +ip(loopback) -> + [{ip, {127,0,0,1}}]; +ip(Addr) -> + [{ip, Addr}]. + +addr(loopback) -> + {127,0,0,1}; addr(A) -> A. |