[erlang-questions] Noob Question ...

fess <>
Fri Mar 6 03:38:01 CET 2009


{function_clause,[{test,client,[8021]}, ...

{function_clause,[{Module,Function,Args}, ...  where Args is a list of  
arguments that was passed.

it means you don't have a function that matches the call  
test:client(8021)

your function definition:

   client([Port]) ->
     ...

means client takes a list of one as it's only argument.   [ so  
test:client([8021]) works, but test:client(8021) does not match. ]

try this

   client(Port) ->
     ...

which means take one argument.

the magic is learning the syntax of function clause, case clause,  
badarg, etc,
I don't have the answer where the good docs are on that.  perhaps  
joe's book is best?
I hope there's a good answer to get people past that bit quicker.

hope that helps.

--fess


On Mar 5, 2009, at 6:22 PM, Shelby Ramsey wrote:

> Hello!
>
> I'm trying to become an erlang convert (from Python) and I do mostly  
> network programming.
>
> So I wrote up this little tidbit:
>
> -module(test).
> -export([client/1]).
>
> client([Port]) ->
>     case gen_tcp:connect("127.0.0.1", Port, [list,{packet,0}]) of
>         {ok, Socket} ->
>             gen_tcp:send(Socket,"auth iltd!dy69?\r\n\r\n"),
>             gen_tcp:send(Socket,"event plain text\r\n\r\n"),
>             loop(Socket);
>         {error, Reason} ->
>             print_stuff([Reason]),
>             ok
>     end.
>
> loop(Socket) ->
>     case gen_tcp:recv(Socket, 0) of
>         {ok, Data} ->
>             print_stuff([Data]),
>             loop(Socket);
>         {error, closed} ->
>             ok
>     end.
>
> print_stuff([Text]) ->
>     io:format("~w", [Text]).
>
> It compiles ... but when I run ... well ... it spits this:
>
> =ERROR REPORT==== 5-Mar-2009::20:19:27 ===
> Error in process <0.30.0> with exit value: {function_clause, 
> [{test,client,[8021]},{erl_eval,do_apply,5},{shell,exprs,6}, 
> {shell,eval_loop,3}]}
>
> ** exited: {function_clause,[{test,client,[8021]},
>                              {erl_eval,do_apply,5},
>                              {shell,exprs,6},
>                              {shell,eval_loop,3}]} **
>
>
> So what did I hose up?  And more importantly ... where is some  
> documentation re: how to debug the "error report".
>
> Thanks for any assistance!
>
> SDR
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions

--fess






More information about the erlang-questions mailing list