[newbie] Erlangish way of Iterator pattern

Gaspar Chilingarov nm@REDACTED
Tue Jan 25 23:23:47 CET 2005


> Gaspar Chilingarov wrote:
> ...deleted
>> what i have in erlang -- i have erlang process, which can accept data
>> messages and eof messages and do processing. another process hangs
>> around, waiting for TCP connection and feeding first process with data
>> read from TCP. in the same time i have shell script which runs once a
>> minute and feeds data from some file(or piped command line) to TCP port.
>
> please note that it is possible to use active mode (see
> http://www.corelatus.com/~matthias/modules.html the gen_tcp module).
> unless you want a permanent process for processing, you could let the
> process that waits for a tcp connection start a new process and redirect
> (gen_tcp:controlling_process/2) the incoming messages to the new process.

as far as i can understand, there is no way to implement gen_server behavior
when using gen_tcp ? i stuck, because i cannot think of place, where i should
put accept() call :)


>
>> now i want to get rid of shell script, but i wish to have separate
>> module which will do this -- i.e. 1. running periodically external
>> command, 2. feeding to another process.
>>
>> are there any idioms in Erlang for this or it should be implemented in
>> straight way -- i.e. just another process sitting there and doing it's
>> job -- file reading/parsing/feeding to another process ?
>
> i would recommend just another process. look at timer:apply_interval/4
> if you want to run something periodically.
>
>
> bengt
>

ok, already done.




More information about the erlang-questions mailing list