<pre>*** 2nd submission, readable version ***<br>*** Please delete fist version ***<br><br>I have now been programming in Erlang for<br>quite a while and most things are really<br>easy to do, but I found some rather tough<br>issues, here the come:<br><br>1)  When using the example server from the<br>man pages of the gen_tcp / inet unit I have<br>tried to create an auto update routine,<br>which does a sort of <br>?MODULE:loop(<some parameters>), <br>but it seems that the sockets just won't let<br>go, stick to the running module and as <br>expected under the circunstances, after the<br>second update Erlang moves the sockets out<br>of the VM and ends the processes, so I cannot<br>create a socket server which permits to be<br>updated in runtime.   <br><br>Just for info, under any other cicumstances<br>I have managed to create all my other modules<br>to be updatable and it works just fine, <br>except this simple socket server ??   Does<br>gen_tcp have problems to do the
 typical <br>?MODULE:loop(X) ??   <br><br>2)  Erlang describes that one can limit the <br>size of the packet to be received by a socket, <br>if it's longer it gets marked invalid and I <br>would suppose that it gets dropped, the <br>parameter is called packet_size.   I would <br>like to limit the packets to be received to <br>be of X size, the example below shows 255, <br>yet I can successfully send large packets to <br>the socket, what's wrong ??   Note: Why do I <br>want this ??   I want to avoid problems where <br>hackers do a buffer overrun hack and crash the <br>server by sending many large packets which then <br>write to memory at some point or crash the <br>server because it exhausts memory, something <br>very common in Windows hacks.  inet states that <br>much depends on the underlying OS, which is <br>Windows in this case, but I do not know if <br>this parameter depends on the OS.<br><br>Example:<br>case gen_tcp:listen(LPort,[{active, false},<br>{packet_size, 255},
 {packet,0},<br>{recbuf, 255},{sndbuf, 255}]) of<br>        {ok, ListenSock} -><br>        ........<br>I have even used recbuf and sndbuf which do <br>not seem to do anything either.<br><br>3) Also, I am writing a small scripted client<br>to test the server part, now, when I am <br>bombarding the server with messages and ask <br>it to send these to the other processes I face <br>the following problem:   first of all and <br>thankfully, Erlang keeps up, the server <br>does not seem to crash, yet, when a client <br>finally crashes with a stack overflow <br>(problably a memory leak or too much data), <br>this particular acceptor on the server side <br>does not exit, although I have included code <br>to make sure that the exit gets trapped, yet <br>this process stays alive, instead of closing.   <br>My question here is has anyone faced this <br>before ??   When a client exits normally no <br>problem ocurrs, only when it crashes.<br><br>4) I am building a command parser which
 needs <br>to parse in commands of the structure <br>{CMD:DETAIL}.   Each time the server receives <br>a packet it may receive several commands of <br>this structure, which is why I need to parse <br>a list of commands and the parsing code could <br>look like this:<br><br>parsecmd(T) -><br>    parseusr(T, []).<br><br>parscmd("{USR:" ++ T, L) -><br>    {Url, T1} = collect_cmd(T, reverse("")),<br>    parsecmd(T1, [Url|L]);<br><br>parsecmd([_|T], L) -><br>    parsecmd(T, L);<br><br>parseusr([], L) -><br>    L.<br><br>collect_cmd("}" ++ T, L) -> {reverse(L, ""), T};<br>collect_cmd([H|T], L)       -> collect_cmd(T, [H|L]);<br>collect_cmd([], _)          -> {[],[]}.<br><br>I would like to call parsecmd(<CMD>,<LIST TO PARSE>)<br>The problem is that I cannot pass <br>"{CMD:" as a parameter, like in the above <br>"{USR:", if I do Erlang complains that it <br>cannot process that structure, where <br>"{CMD:" is a list.   Is there any way this <br>can
 be parametrized ??   Or is there another <br>function ??   And no, I have not used YECC, <br>because I find its working incomprehensible.   <br>I can already parse several commands when I <br>search separately for "{", "}" and ":" but <br>not for "{CMD:" and "}", where CMD is a <br>variable that I want to pass to the parsing <br>function.<br><br>Any help is appreciated, I have researched <br>different unit'mans, the whole Erlang Bible, <br>other examples but I cannot find a solution <br>to those 4 issues, so I am turning to the <br>ever so wise community.  <br><br>Thanks in advance,<br><br>Bo</pre> <p>

      <hr size=1>You rock. That's why Blockbuster's offering you <a href="http://us.rd.yahoo.com/evt=47523/*http://tc.deals.yahoo.com/tc/blockbuster/text5.com">one month of Blockbuster Total Access</a>, No Cost.