Skip to content

Commit

Permalink
preliminary support for erlang type
Browse files Browse the repository at this point in the history
SVN Revision: 1064
  • Loading branch information
nniclausse committed Jan 14, 2010
1 parent 8f798e8 commit ff3194d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tsung/ts_client.erl
Expand Up @@ -687,7 +687,8 @@ reconnect(Socket, _Server, _Port, _Protocol, _IP) ->
%%----------------------------------------------------------------------
send(gen_tcp,Socket,Message,_,_) -> gen_tcp:send(Socket,Message);
send(ssl,Socket,Message,_,_) -> ssl:send(Socket,Message);
send(gen_udp,Socket,Message,Host,Port) ->gen_udp:send(Socket,Host,Port,Message).
send(gen_udp,Socket,Message,Host,Port) ->gen_udp:send(Socket,Host,Port,Message);
send(erlang,Pid,Message,_,_) -> Pid ! Message.

%%----------------------------------------------------------------------
%% Func: connect/4
Expand All @@ -696,6 +697,9 @@ send(gen_udp,Socket,Message,Host,Port) ->gen_udp:send(Socket,Host,Port,Message).
connect(gen_tcp,Server, Port, Opts) -> gen_tcp:connect(Server, Port, Opts);
connect(ssl,Server, Port,Opts) -> ssl:connect(Server, Port, Opts);
connect(gen_udp,_Server, _Port, Opts)-> gen_udp:open(0,Opts).
connect(erlang,Server,Port,Opts) ->
Pid=spawn(ts_erlang,client,[self(),Server,Port,Opts]),
{ok, Pid}.


%%----------------------------------------------------------------------
Expand Down
39 changes: 39 additions & 0 deletions src/tsung/ts_erlang.erl
@@ -0,0 +1,39 @@
%%%
%%% Copyright 2009 © INRIA
%%%
%%% Author : Nicolas Niclausse <nniclaus@sophia.inria.fr>
%%% Created: 20 août 2009 by Nicolas Niclausse <nniclaus@sophia.inria.fr>
%%%
%%% This program is free software; you can redistribute it and/or modify
%%% it under the terms of the GNU General Public License as published by
%%% the Free Software Foundation; either version 2 of the License, or
%%% (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%%% GNU General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
%%%

-module(ts_erlang).
-vc('$Id: ts_erlang.erl,v 0.0 2009/08/20 16:31:58 nniclaus Exp $ ').
-author('nniclaus@sophia.inria.fr').


export([client/4]).

client(MasterPid,Server,Port,Opts)->
receive
{msg, Module, Fun, Args} ->
Res=apply(Module,Fun,Args),
MasterPid ! {erlang,self(),Res},
client(MasterPid,Server,Port,Opts)
after ?TIMEOUT ->
MasterPid ! timeout
end.


0 comments on commit ff3194d

Please sign in to comment.