1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2018-2019. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20 21-module(socket_test_ttest_tcp_client_socket). 22 23-export([ 24 start/4, start/5, start/7, start/8, 25 stop/1 26 ]). 27 28-define(TRANSPORT_MOD, socket_test_ttest_tcp_socket). 29-define(MOD(D, A, M), {?TRANSPORT_MOD, #{domain => D, 30 async => A, 31 method => M}}). 32 33start(Method, Async, Active, ServerInfo) 34 when is_list(ServerInfo) -> 35 Domain = local, 36 socket_test_ttest_tcp_client:start_monitor(?MOD(Domain, Async, Method), 37 ServerInfo, Active); 38start(Method, Async, Active, ServerInfo = {Addr, _}) 39 when is_tuple(Addr) andalso (size(Addr) =:= 4) -> 40 Domain = inet, 41 socket_test_ttest_tcp_client:start_monitor(?MOD(Domain, Async, Method), 42 ServerInfo, Active); 43start(Method, Async, Active, ServerInfo = {Addr, _}) 44 when is_tuple(Addr) andalso (size(Addr) =:= 8) -> 45 Domain = inet6, 46 socket_test_ttest_tcp_client:start_monitor(?MOD(Domain, Async, Method), 47 ServerInfo, Active). 48 49start(Method, Async, Active, ServerInfo, MsgID) 50 when is_list(ServerInfo) -> 51 %% This is just a simplification 52 Domain = local, 53 socket_test_ttest_tcp_client:start(?MOD(Domain, Async, Method), 54 ServerInfo, Active, MsgID); 55start(Method, Async, Active, ServerInfo = {Addr, _}, MsgID) 56 when is_tuple(Addr) andalso (size(Addr) =:= 4) -> 57 %% This is just a simplification 58 Domain = inet, 59 socket_test_ttest_tcp_client:start(?MOD(Domain, Async, Method), 60 Active, ServerInfo, MsgID); 61start(Method, Async, Active, ServerInfo = {Addr, _}, MsgID) 62 when is_tuple(Addr) andalso (size(Addr) =:= 8) -> 63 Domain = inet6, 64 socket_test_ttest_tcp_client:start(?MOD(Domain, Async, Method), 65 ServerInfo, Active, MsgID). 66 67start(Method, Async, Active, ServerInfo, MsgID, MaxOutstanding, RunTime) 68 when is_list(ServerInfo) -> 69 Domain = local, 70 socket_test_ttest_tcp_client:start(false, 71 ?MOD(Domain, Async, Method), 72 ServerInfo, Active, 73 MsgID, MaxOutstanding, RunTime); 74start(Method, Async, Active, ServerInfo = {Addr, _}, 75 MsgID, MaxOutstanding, RunTime) 76 when is_tuple(Addr) andalso (size(Addr) =:= 4) -> 77 Domain = inet, 78 socket_test_ttest_tcp_client:start(false, 79 ?MOD(Domain, Async, Method), 80 ServerInfo, Active, 81 MsgID, MaxOutstanding, RunTime); 82start(Method, Async, Active, ServerInfo = {Addr, _}, 83 MsgID, MaxOutstanding, RunTime) 84 when is_tuple(Addr) andalso (size(Addr) =:= 8) -> 85 Domain = inet6, 86 socket_test_ttest_tcp_client:start(false, 87 ?MOD(Domain, Async, Method), 88 ServerInfo, Active, 89 MsgID, MaxOutstanding, RunTime). 90 91start(Quiet, Async, Active, Method, ServerInfo, MsgID, MaxOutstanding, RunTime) 92 when is_list(ServerInfo) -> 93 Domain = local, 94 socket_test_ttest_tcp_client:start(Quiet, 95 ?MOD(Domain, Async, Method), 96 ServerInfo, Active, 97 MsgID, MaxOutstanding, RunTime); 98start(Quiet, Async, Active, Method, ServerInfo = {Addr, _}, 99 MsgID, MaxOutstanding, RunTime) 100 when is_tuple(Addr) andalso (size(Addr) =:= 4) -> 101 Domain = inet, 102 socket_test_ttest_tcp_client:start(Quiet, 103 ?MOD(Domain, Async, Method), 104 ServerInfo, Active, 105 MsgID, MaxOutstanding, RunTime); 106start(Quiet, Async, Active, Method, ServerInfo = {Addr, _}, 107 MsgID, MaxOutstanding, RunTime) 108 when is_tuple(Addr) andalso (size(Addr) =:= 8) -> 109 Domain = inet6, 110 socket_test_ttest_tcp_client:start(Quiet, 111 ?MOD(Domain, Async, Method), 112 ServerInfo, Active, 113 MsgID, MaxOutstanding, RunTime). 114 115stop(Pid) -> 116 socket_test_ttest_client:stop(Pid). 117