<div dir="ltr">dispatchloop is expecting a list but you are giving it a binary.<br><br>You probably want something like <br><br><span style="font-family: courier new,monospace;">dispatchloop(<<>>, Working) -></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> Working;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">dispatchloop(<<$#,Rest/bytes>>, Working) -></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> callcommand(Working),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dispatchloop(Rest, []);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">dispatchloop(<<_Skip,Rest/bytes>>, Working) -></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dispatchloop(Rest, Working).</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">HTH<br><br><div class="gmail_quote">On Thu, Sep 4, 2008 at 3:34 PM, Timothy Baldridge <span dir="ltr"><<a href="mailto:tbaldridge@gmail.com">tbaldridge@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Well, I'm finally making the dive into Erlang programming. I have<br>
project at work here that I'm using to learn with. Basically this<br>
program will connect to a tcp server. Then it will begin to parse info<br>
that the server spits out. The data is in this format (plaintext):<br>
<br>
command|arg1|arg2#command2|arg2#<br>
<br>
So # separates commands and | separates phrases. Here's the code I have so far:<br>
<br>
-module(filemonitor).<br>
-export([start/1, dispatchloop/2]).<br>
<br>
start(Ip) -><br>
{ok, Socket} = gen_tcp:connect(Ip, 9442, [binary]),<br>
loop(Socket, []).<br>
<br>
loop(Socket, Buffer) -><br>
receive<br>
{tcp, Socket, Bin} -><br>
io:format("~p~n", [Bin]),<br>
Newbuff = dispatchloop(Bin, Buffer),<br>
loop(Socket, Newbuff);<br>
{tcp_error, Socket, Reason} -><br>
io:format("Error ~p~n", [Reason]),<br>
gen_tcp:close(Socket);<br>
{tcp_closed, Socket} -><br>
io:format("Connection Terminated~n")<br>
end.<br>
<br>
<br>
<br>
callcommand(Working) -><br>
io:format("~s~n", [Working]).<br>
<br>
dispatchloop([],Working) -><br>
Working;<br>
dispatchloop([H|T], Working) -><br>
if<br>
H == "#" -><br>
callcommand(Working),<br>
dispatchloop(T, []);<br>
true -><br>
dispatchloop(T, Working)<br>
end.<br>
<br>
<br>
I get this error:<br>
<br>
4> filemonitor:start("<a href="http://192.168.101.170" target="_blank">192.168.101.170</a>").<br>
<<"getattr|/#">><br>
** exception exit: function_clause<br>
in function filemonitor:dispatchloop/2<br>
called as filemonitor:dispatchloop(<<"getattr|/#">>,[])<br>
in call from filemonitor:loop/2<br>
<br>
<br>
Any ideas I'm stumped....<br>
<br>
Thanks,<br>
<br>
Timothy<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote></div><br></div>