%%% This line tells emacs that this is -*-erlang-*- code. %%% ------------------------------------------------------- %%% Copyright : Ericsson Radio Systems AB 1996 %%% File : client.erl %%% Rev : PA1 %%% Date : Thu Sep 26 08:40:05 1996 %%% Author : Johan Garpendahl Z/XE %%% Slogan : %%% ------------------------------------------------------- -module(client). -rcs('$Id$'). -who_am_i('address@hidden'). -export([connecttest/0, messagetest/0]). -define(KALLE_KALLE, 2) connecttest() -> socket:start(), io:format("Time ~w.\n", [time()]), call2(1000), io:format("Time ~w.\n", [time()]). messagetest() -> socket:start(), io:format("Time ~w.\n", [time()]), call(1000), io:format("Time ~w.\n", [time()]). %% ------------------------------------------------------- %% Connect & Meddelandeöverföring %% Ändra y01u522 till localhost eller datornamn %% ------------------------------------------------------- call(0) -> ok; call(Times) -> S = socket:client(?KALLE_KALLE, 'AF_INET', {y01u522, 3000}, {packet, 2}), S ! {self(), {deliver, "Hejhopp"}}, receive {S, {fromsocket, "Hejhopp"}} -> socket:close(S), call(Times - 1) end. %% ------------------------------------------------------- %% Connect %% Ändra y01u522 till localhost eller datornamn %% Testa gärna att ta bort sleepen. %% Då tar det längre tid! %% ------------------------------------------------------- call2(0) -> ok; call2(Times) -> S = socket:client('STREAM', 'AF_INET', {y01u522, 3000}, {packet, 2}), sleep(), socket:close(S), call2(Times - 1). sleep() -> receive after 10 -> ok end.