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