[erlang-questions] Noob Question ...

Richard Andrews bbmaj7@REDACTED
Fri Mar 6 12:50:13 CET 2009



The immediate thing that strikes me is that "127.0.0.1" should be {127,0,0,1}. In gen_tcp (erlang in general) the address is a tuple not a string.

See man 3 inet for more info.

Debugging becomes easier with experience. function_clause means you tried to call a function with the wrong argument type. Probably because you tried to pass a list (aka string) instead of a tuple to connect().

The rest of that section after function_clause is a stack trace. In this case it doesn't tell you much but it would be helpful if the failure occurred deeper into a call stack.

________________________________

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.


      Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox



More information about the erlang-questions mailing list